But another scene is :when there is a "public" class in a java file, then you must create the "main" method in this class,not the other "non-public"class.So why? I think the position of "main" method doesn't matter with the access control modifiers!
This is not true. Consider this :
Compile it and name it test.java. As
test is a public class. Compile the file. It will create two files test.class and test1.class. The command line java is used to start a class's main() maethod. So when you do java test it will give you an error because it doesn't has a main method. Instead
you should do java test1 which would then execute the required file. If you want both the classes can have a main method and you can decide which one you want to execute.