jQuery in Action, 3rd edition
The moose likes Performance and the fly likes Import package.* Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Import package.*" Watch "Import package.*" New topic

Import package.*

James Inge

Joined: Dec 04, 2000
Posts: 12
I was wondering if there are any performance or class 'bloat' issues associated with using the import of package.* versus including only the classes which you are using?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I think that importing more classes than you need has no effect on run-time performance.
The import statement affects which classes should be made available by class name only, so that they may be referenced in the source without their package prefix, during compilation. However, this does not affect which files get loaded, or how much memory gets used when running.
I do not know whether the compiler goes slower, faster or about the same speed if import packagexxx.* is used, compared to individual imports.
However, for clarity and to avoid namespace clashes (class with same name in two packages -> confusion), I think that developers should always explicitly import individual classes, even if it makes for a rather long prolog to the source file.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link: http://aspose.com/file-tools
subject: Import package.*
It's not a secret anymore!