Would it suppose any difference regarding overhead to write an import loading all the types within one package (import java.*
); than just a specific type (i.e. import java.lang.ClassLoader
)? Would the second one be a more advisable way to use than the other one?
Take a look at the java API, and you'll see many classes and interfaces with the same name in different packages.
For example:
java.lang.reflect.Array
java.sql.Array
So, if you import java.lang.reflect.*
and java.sql.*
you'll have a collision on the Array type, and have to fully qualify them in your code.
Importing specific classes instead will save you this hassle.