假设我有一个名为 Main.java 的文件,其代码如下:
Let's assume I have a file named Main.java with the following code:
public class Main {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
它是否放在一个特定的包中,在(也许?)一个未命名的包中?
Is it put in a specific package, in (maybe?) an unnamed package?
谢谢
不在命名包中的类在 未命名包.因此完整的类名是Main
.
A class that is not in a named package is in an unnamed package. Thus the full class name is Main
.
此类类不能使用命名包,但通过反射除外.
Such classes cannot be used from a named package, except via reflection.
JLS 说:
Java SE 平台提供未命名的包主要是为了方便开发小型或临时应用程序或刚开始开发时.
Unnamed packages are provided by the Java SE platform principally for convenience when developing small or temporary applications or when just beginning development.
这篇关于如果我不指定,我的课程放在哪个默认包中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!