• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt about public??  RSS feed

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it mandatory that one class has to be declared public if a particular file has more then one class in a single java file??
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't beleive so. I think the rule is you cannot have MORE THAN one public class, but you can have 0.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may i know the reason why is that if there is a single public class in a group of classes in a single java file ,then why we have to name the file as one whose class was declared public?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
again, i am not 100% sure, but i believe it is to make life easier for the folks who write the JVM.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Fred
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fred Rosenberger:
again, i am not 100% sure, but i believe it is to make life easier for the folks who write the JVM.


The folks who write the compiler.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!