• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Public class

 
Ganesh Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why only one public class is allowed per source code file? what they are achieving by having that rule?
 
Anuragk kushwaha
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ganesh,,

JVM is a program which is outside your package. since execution point of any prog is main() which must be defined in a public class, because it is accesed by jvm which is outside the package.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Oak 0.2 specification appears to suggest this was a performance optimization.
Although each Oak compilation unit can contain multiple classes or interfaces, at most one class or interface per compilation unit can be public... This restriction is ... necessary for efficient package importation.

Ref: Once Upon an Oak.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic