aspose file tools*
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "imports statement." Watch "imports statement." New topic
Author

imports statement.

ManavChowdary Chalasani
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


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

Joined: Oct 20, 2005
Posts: 257

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.
 
subject: imports statement.