This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes import  package.*   Vs  package.requiredClass1 ,  package.requiredClass2 ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "import  package.*   Vs  package.requiredClass1 ,  package.requiredClass2 ..." Watch "import  package.*   Vs  package.requiredClass1 ,  package.requiredClass2 ..." New topic
Author

import package.* Vs package.requiredClass1 , package.requiredClass2 ...

Ant Swa
Greenhorn

Joined: May 28, 2002
Posts: 13
Hi,
When I import some classes in a package,
is there a significant advantage (in terms of optimization)
of importing each required class in a separate line, rather than using the * sign.
I know one advantage is the clarity. (one can easily find what are the classes used in the program by looking at the import list)
??


Anton
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
And the answer is ... no.
See for example :
Import overhead
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I'd also add to that article that sometimes importing a whole package "on demand" can cause confusion to the compiler. Imagine the folowing statements:

Oops, both java.util and java.awt have a List class, which one do you mean?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
wood burning stoves
 
subject: import package.* Vs package.requiredClass1 , package.requiredClass2 ...
 
Similar Threads
Importing Alternate Layout Managers
Difference between java.util.* and java.util.HashMap
why one can not import classes from default package in java?
import statements in java
struts.upload