Why we can have only public class per java file? Is there any specific technical reson about that constrain? or any predefined JVM rule or else??
Thanx ...
The compiler needs to be able to find classes that may not yet have been compiled.
If source code for a class can have any file name, or is hidden together with other
class sources, the compiler can't find it.
The compiler needs to be able to find classes that may not yet have been compiled.
If source code for a class can have any file name, or is hidden together with other
class sources, the compiler can't find it.
kind regards,
Jos
Jos yet its not clear....plz explain it in as simple way as possible...
Jos yet its not clear....plz explain it in as simple way as possible...
thanx...
Suppose you have two public classes A and B and also suppose an A object
creates or uses or refers to a B object.
When you compile A.java the compiler notices that a B object is used. Suppose
there's no B.class yet (B has not been compiled yet). The Javac compiler starts
searching for a source file B.java in order to compile it too. Suppose the name
could be anything; how is the compiler supposed to find the source for class B?
Comment