Files with no public classes can have a name that does not match any of the classes in the file.
if you declare a class A in a file called X.java as follows ::
class A{
------
}
the class will compile correctly.
But if you declare the class A as ::
public class A{
}
this will result in an error as --- ( class A is public, must be declared in a file A.java )
This comes under Source File Declaration Rules as defined by java Developers.
No comments:
Post a Comment