This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

imports statement.

 
ManavChowdary Chalasani
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between import package.* and import package.class in java? Performance wise? I know the basic difference , like using "*" imports all the classes and using the "package.class" only a particular class in the package. I want more in detail.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the [url=http://"http://faq.javaranch.com/view?WildCardVsSpecificImports"]JavaRanch FAQ entry on this topic.[/url] This question is asked very often.

Short answer: performance-wise, there's no detectable difference whatsoever, either at runtime or compile time. Which you use is a matter of taste; most experienced practitioners recommend the individual class imports.
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The individual import statements increases the readability of the program and it will be very clear which classes have been used.

In terms of performance there is no significance difference and more over .* will not include all classes, but will search for whole package to find the correct class to load.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic