Question

I would like to know how can I avoid to make IntelliJ IDEA to automatically consolidate all the classes of a package with the *. For exameple let's say I have the following classes imported:

import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;

now if I write later on a bit of code like the following:

List list = new ArrayList();

I can type alt + enter on either List or ArrayList in order to automatically import them. The problem is that once I do that, automatically IntelliJ IDEA consolidates all the imports with java.util.* instead of adding the single class.

I have seen the tab "organize imports" but it's not what I am looking for. What I would like to have is that in such case as the one I have above described, when typing alt + enter I get added the single class along the others of the same package rather than having all of them consolidated in java.util.*;.

Does anybody know how to do that?

Was it helpful?

Solution

Open the Settings: Code style -> Java -> Import Tab in the first section (General) there is an option for Use single class import and at the end of the section two value fields where you can set the limit of classes in the imported package until idea starts to import *

OTHER TIPS

Note that in IntelliJ 14, Ultimate there is also an option under: SETTINGS | EDITOR | CODE STYLE | JAVA | IMPORTS | to "Use fully Qualified class names".

If you check this it will NOT import your classes (as long as they're in your classpath).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top