Possible Duplicate:
Any reason to clean up unused imports in Java, other than reducing clutter?
Please let me know if we put 1000 of import statement will it slow down execution of code?
Possible Duplicate:
Any reason to clean up unused imports in Java, other than reducing clutter?
Please let me know if we put 1000 of import statement will it slow down execution of code?
No, there is no performance penalty for import statements. They are not "executed" in runtime, they just help compiler to locate correct classes.
You can have zero import statements and rewrite all your class references to full class names (including packages), i.e. instead of:
import java.util.Collection;
import java.util.ArrayList;
Collection myColl = new ArrayList();
you can always write:
java.util.Collection myColl = new java.util.ArrayList();
This code is equivalent to the version above. It's just more verbose.
It shouldnt, no - import statements are used for name resolution.
I suspect it may have an impact on compile time though.
At the end of the day, though - you need as many import statements as you need to unambiguously resolve all the classes you use - its not something you can easily 'optimise'
No it is even in most cases much better to write for instance:
import java.util.Collection;
import java.util.ArrayList;
import ...
then
import java.util.*;
Edit: for reasons of readability of your code and compiler performance.