Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Handling Imports

When you use the IDE's code completion and editor hints features, import statements are generated for you automatically.

For example, if you have the code completion box open and you start typing a simple class name instead of its fully-qualified class name (e.g., you type Con and then select ConcurrentHashMap from the code completion box), the following import statement will be added to the beginning of the file:

  import java.util.concurrent.ConcurrentHashMap;

For cases where these mechanisms are not sufficient for the management of import statements, you can use the following commands:

  • Fix Imports (Alt-Shift-F), which automatically inserts any missing import statements for the whole file. Import statements are generated by class (rather than by package). For rapid management of your imports, use this command.
  • Fast Import (Alt-Shift-I), which enables you to add an import statement or generate the fully qualified class name for the currently selected identifier. This command is useful if you want to generate an import statement for a whole package or if you want to use a fully qualified class name inline instead of an import statement.
  • + Share This
  • 🔖 Save To Your Account