Explain Codes LogoExplain Codes Logo

Disabling 'Starred' (Package) Imports in IntelliJ?

java
intellij
package-imports
ide-settings
Anton ShumikhinbyAnton Shumikhin·Nov 24, 2024
TLDR

To disable IntelliJ's default auto import behaviour which uses star (package) imports:

Preferences/Settings > Editor > Code Style > Java > Imports: Class count to use import with '*': 999 Names count to use static import with '*': 999

Bump up the values for both Class count and Names count to 999. Voilà! The age of star imports is over, be it regular or static imports.

Guided fine-tuning of import settings IntelliJ IDEA is all about personalization. Here's how to curate your import settings:

  1. Highlight packages you use less in the auto-import feature to prevent importing the entire shebang.
  2. Dial in your static import settings to optimize readability when invoking static members like it's going out of style. 😉
  3. Filter the pre-configured imports to avoid blind star imports.
  4. Be on the lookout for version-specific configurations if you update IntelliJ regularly - you don't want to lose your personal touch!

Retrace these steps to accommodate your evolving coding preferences, and recapture the warm, fuzzy feeling from using your previous IDE.