File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ant Swa
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
??
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the answer is ... no.
See for example :
Import overhead
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic