Its not compulsory that a public method should present in the java source file.
Note: If public class presents then only one class for one source allowed and the name of the source file must match.
Javac will generate .class files for all classes which are coded in the source file and you can have main in each and every class, there is no problem in that.
It will take the main from the class which , will be mentioned at java <className>
Joined: Aug 16, 2006
its not a mandatory rule that a class containing main method should have access modifier as public....the rules are as following:
1. class in a file can have access modifier as either public or default. 2. if there are more than one class in a file one class can be public at max(but public access is not mandatory for any class even now). 3. the file name should match the public class.