Java – if you do not specify my class, what is the default package for my class?
•
Java
Let's say I have a name called main Java file, the code is as follows:
public class Main { public static void main(String[] args) { System.out.println("Hello world"); } }
It is placed in a specific package in (perhaps?) An unnamed package?
thank you
Solution
The class that is not in the named package is unnamed package Therefore, the full class name is main
Except through reflection, these classes cannot be used from named packages
JLS said:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码