• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why do we have atmost one public class in a source file

 
divyasheel sharma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
Pls explain me why do we have only one public class atmost in a source file and why the class name shall match the unextended file name, is this a convention? Why?
Rgds
Divya

------------------
Eat Java,Drink Java...surf only Javaranch!
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Divya,
The reason for this is to force a coding convention onto programmers. If you are looking at somebody else's source, then all you should be interested in is the public classes. If the public classes are in files of the same name, its easy to find them. I believe thats the the theory anyway...

------------------
- Daniel
 
divyasheel sharma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Daniel!
-Divya
------------------
Eat Java,Drink Java...surf only Javaranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic