File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: import package.* Vs package.requiredClass1 , package.requiredClass2 ...
 
Similar Threads
import statements in java
Importing Alternate Layout Managers
Difference between java.util.* and java.util.HashMap
struts.upload
why one can not import classes from default package in java?