IntelliJ Keyboard Shortcut to remove unused imports [Java]

If you are using IDEA IntelliJ IDE for your Java Project and want to remove unused import statements from a Java class file, you can use the keyboard shortcut: Option + Shift + Enter if you are on macOS and Control + Shift + Enter if on Windows

You will see all unused imports in gray color,

IntelliJ Java unused import statements
Keyboard Shortcuts to remove unused Java Import Statements:
macOS:   Option + Shift + Enter
Windows: Alt + Shift + Enter

You may also hover over the un-used imports and select the Optimize Imports

Unused import Optimization IntelliJ
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.