Imports can be categorized as explicit (for example import java.util.List;) or implicit (also known as 'on-demand', for example import java.util.*;):

It is often considered bad practice to use implicit imports. The only advantage to doing so is making the code more concise, and there are a number of disadvantages:

For readability, it is recommended to use explicit imports instead of implicit imports. Many modern IDEs provide automatic functionality to help achieve this, typically under the name "Organize imports". They can also fold away the import declarations, and automatically manage imports: adding them when a particular type is auto-completed by the editor, and removing them when they are not necessary. This functionality makes implicit imports mainly redundant.

The following example uses implicit imports. This means that it is not clear to a programmer where the List type on line 5 is imported from.

To improve readability, the implicit imports should be replaced by explicit imports. For example, import java.util.*; should be replaced by import java.util.List; on line 1.

  • Java Language Specification: 6.4.1 Shadowing, 7.5.2 Type-Import-on-Demand Declarations.