This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Java in General and the fly likes imports statement. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "imports statement." Watch "imports statement." New topic

imports statement.

ManavChowdary Chalasani

Joined: Dec 19, 2003
Posts: 2
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

Joined: Jul 08, 2003
Posts: 24189

Here is the [url=http://""]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.

[Jess in Action][AskingGoodQuestions]
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257


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.
jQuery in Action, 3rd edition
subject: imports statement.
It's not a secret anymore!