This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It is perfectly legal to write the following: You could then compile and run this class
You can also do the following: You can then save this file as Hello.java and compile and run each of the two Test classes, but you can't have two public classes in one .java file because that is the rule and the compiler will not let you get away with it. [ May 25, 2005: Message edited by: Nigel Browne ]
It's a convenience for the compiler. If you reference a class called BowlingGame the compiler knows to look for the source in a file called BowlingGame.java and the compiled code in a file called BowlingGame.class. If not for that rule the compiler might have to look inside all the files in the current directory or your whole classpath to find the one that says "class BowlingGame". Oh, and it's more convenient for us humans, too! [ May 25, 2005: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi