Reputation: 1
I am newbie in programing. I use IntelliJ IDEA v.14.0.
I try to learn some Java basics, but when I enter at the beginning of the import java.util.*;
it becomes
Unused import statement
That happens when I add semicolon at the and of the row. Unused import statement
Instead of just to import import java.util.*;
I have to write in the code every time java.util.Arrays.sort(int_array1);
I tried many different classes to import, but all they become "Unused import statement"
How can I import classes without this problem?
Upvotes: 0
Views: 8749
Reputation: 97123
The import statement is unused when you enter it, because you haven't yet entered the code that uses the import. This is correct and you should not worry about it. Once you enter the code that uses the import, it will no longer be highlighted as unused.
Upvotes: 1
Reputation: 25863
That warning means you're importing a lot of classes that you don't use.
Personally I never use *
. I only import the classes I use. If you have too many imports, it's a sign your class is probably doing too much and you might consider refactoring (see God object).
You can just do like this:
import java.util.Arrays;
Anyway, if you're using IntelliJ (or any IDE), let it handle the imports for you (for IntelliJ: Alt-Enter on the red underlined class -> Import class).
Upvotes: 1