[Aaron Raja]1. What is the reason for allowing only ONE public class per source file? That is the rule Java have. So just follow it.
Well to be precise it's the compiler's rule. Generally compilers enforce such a rule. The java language specification doesn't mandate that a public class should be in it's own file. But till date I haven't heard of any compiler that does not follow this convention. [ June 20, 2007: Message edited by: Anupam Sinha ]
On your way in you may have missed that we have a JavaRanch Naming Policy for displayed (screen) names. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Since yours "nelumd", does not conform with it, please take a moment to change it, which you can do right here.
Posters with nonconforming displayed names will be locked out of JavaRanch after a few posts using those names.
However, I don't see much here about why. The Oak 0.2 specification appears to suggest this was a performance optimization. ("Oak" was the original name for "Java.")
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.
Hello, Thank you for all the replies. I also read "JavaRanch Naming Policy", "Ask a Meaningful Question", and "HowToAskQuestionsOnJavaRanch" which made me realize some of my mistakes and learn alot out of them. Just want to appreciate all the people behind this site, because it's really good. Thank you so much for being patient with us greenhorns and for giving us the opportunity to improve and for saying it as it is.
God Bless You
Clowns were never meant to be THAT big! We must destroy it with this tiny ad: