简体   繁体   中英

Importing Java classes run-time and compilation

Could someone explain what importing java.net.* imports? Also could someone explain briefly how importing say java.swing.* would affect the run-time and compilation.

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.swing.* should have little affect on run-time and compilation because it is written entirely in Java and follows standard class hierarchy rules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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