If a class is used in a Java project in Eclipse, and it’s not imported already, and there is only one class with that name, Eclipse will automatically import it.
If there are two or more classes with the same simple name, Eclipse will ask the user to select the desired one. I would like to avoid having to select one and instead prefer having a default class imported.
For example, I commonly use List and ArrayList. And each time I use them in a new class, I have to select java.util.ArrayList and java.util.List from the suggestions of Eclipse, because there is another class with the name List (java.awt.List).
Is there some way to set java.util.List and java.util.ArrayList as a default import if List and ArrayList is used?
For now, I created an Eclipse template that triggers on the word List. Are there any other ideas or improvements?
${:import(java.util.List,java.util.ArrayList)}
List<> list = new ArrayList<>();
If you don’t use AWT in the project you can limit your accessible API like I mentioned in my blog: http://blog.firdau.si/2010/07/07/limit-your-access-to-java-api-for-more-productivity/
Works like a charm for me!