In Java, the name of the file should be the same as the name of the public class
contained in that file. Why is this a limitation? What purpose does it serve?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
As long as it is not public a class can have a name different from its file name. The class can also have main method. Class file will be generated with the class name but not with the source file name. The class name should be used to execute it.
Reason is: default class is package private, thus javac doesn't have to find this source file of this to compiler some other java program from outside of package.