File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes Code Effectiveness Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Code Effectiveness" Watch "Code Effectiveness" New topic
Author

Code Effectiveness

Fitra Fadilana
Greenhorn

Joined: Jan 06, 2013
Posts: 2

Sometimes i wonder with the convention of writing the import statement in java for effectiveness and best result.
when i read the tutorial in java programming, I often see the writer use all the class inside the package which he/she use in his/her code.
for example:
import javax.microedition.lcdui.*;

after i read the rest of its code, i just noticed it use just one or two class.
for example:
import javax.microedition.lcdui.Canvas;

but why the writer import all unnecessary class.
the question is. what is the impact of importing all the class that we don't need to use.
is it make the code eat much memory when it runs? or it file size if bigger rather than importing necessary class?


<<learn to accomplish>>
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4491
    
    8

It will make almost certainly no difference to the performance, because importing is purely a compile-time operation to remove the need to fully-qualify class names. Having said that, some people do argue that it's better to use explicit imports because it makes the dependencies you're introducing clearer.

I'd use the .* format if it wasn't for the fact that modern IDEs make it easy to handle specific imports - you don't need to type them all out yourself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code Effectiveness