+ 1
file name in java
why public classes must be same with the file name ? and classes with default access modifiers ( package ) dont need to be same with file name?
1 Antwort
+ 1
https://www.quora.com/Why-does-java-file-name-must-be-same-as-public-class-name
this will be of some help.
In short, it's a standard, and one that helps programs find the correct class files. Because public classes are intended to be used/found by other classes this helps speed up the process.
I believe that even when you have multiple classes in a file, or nested/inner classes they are all essentially treated as separate classes, "top level" classes don't really mean anything in the compiled code