Partner – Codium – NPI (cat = IDE)
announcement - icon

Explore the secure, reliable, and high-performance Test Execution Cloud built for scale. Right in your IDE:

>> CodiumAI. Meaningful Code Tests for Busy Devs

Basically, write code that works the way you meant it to.

Course – LS – All

Get started with Spring and Spring Boot, through the Learn Spring course:

>> CHECK OUT THE COURSE

1. Overview

This brief tutorial will describe each option of IntelliJ IDEA’s ‘auto-import’ feature.

2. Auto-import

There are several options in IntelliJ IDEA that we may configure in Settings > Editor > Auto Import:import1

Let’s review each of these options.

2.1. Show Import Popup

When enabled, IDEA will underline a class reference in our code and suggest an import to add:

import2

If there are several options to choose from, Idea will let us choose an import from a list of alternatives:import3

2.2. Optimize Imports on the Fly

This one will make IDEA remove unused imports automatically and rearrange others according to the ‘Code Style’ preferences.

2.3. Add Unambiguous Imports on the Fly

Also, there is a way to automatically add an import as we add references to classes that need to be imported.

2.4. Show Import Suggestions for Static Methods and Fields

Our final option will enable the import popup feature for statics.

However, note that turning only this option on (without ‘Show import popup’) will not enable import suggestions for classes:import4

3. Conclusion

Some developers prefer to have total control over the imports in their classes, others rely on the IDE to handle this technical task.

Either of them may benefit from various configuration options that IntelliJ IDEA IDE has, including those for importing behavior.

Course – LS – All

Get started with Spring and Spring Boot, through the Learn Spring course:

>> CHECK OUT THE COURSE
res – REST with Spring (eBook) (everywhere)
Comments are closed on this article!