Java auto imports with star

Answered

Dear JETBRAINS team, 

I would like to know why the parameter "Class count to use import with '*'" is so low and so intellij adds some imports '*' ?

I agree there is no performance issue because the same bytecode is generated with or without import '*'.

However, to my mind, using '*' may be hiding the complexity of a class. 50 lines of imports can show a complex class. However, if 50% of the imports is hidden by  imports '*', the class may seems less complex.

Please advise

0
1 comment

Hello,

Whether to use imports with asterisk or not is a subjective question.

Asterisk import has a number of advantages like:

- you don't need to scroll a big amount of imports while class content reading;

- you don't need to import each class of one package each time you use it for the first time etc.

Of course there are disadvantages of such an import style like i.e name ambiguities, but this should be taken care of by the IntelliJ IDEA (in case it doesn't, please file a bug at YouTrack: https://youtrack.jetbrains.com/issue).

So it's up to you to decide how to define this parameter. You may change its default value for all new projects in "Preferences for new projects".

 

 

0

Please sign in to leave a comment.