简体   繁体   English

导入Java类运行时和编译

[英]Importing Java classes run-time and compilation

Could someone explain what importing java.net.* imports? 有人可以解释导入java.net.*导入的内容吗? Also could someone explain briefly how importing say java.swing.* would affect the run-time and compilation. 也有人可以简单解释一下导入说java.swing.*会影响运行时和编译。

Importing a package, class, or any class member simply makes it possible to use that component's Simple Name instead of needing to use its Fully Qualified name. 导入包,类或任何类成员只需使用该组件的简单名称,而不是需要使用其完全限定名称。 It doesn't affect runtime. 它不会影响运行时。 It is a compilation feature. 这是一个编译功能。 So instead of having to write 所以不必写

java.net.URL url = ...

you could simply write 你可以简单地写

URL url = ...

it won't affect performance or anything like that. 它不会影响性能或类似的东西。

java.net.* will import all classes of the java.net package. java.net.*将导入java.net包的所有类。 java.swing.* should have little affect on run-time and compilation because it is written entirely in Java and follows standard class hierarchy rules. java.swing.*应该对运行时和编译几乎没有影响,因为它完全用Java编写并遵循标准的类层次结构规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM