Java - Class import Declarations

What is import Declaration?

An import declaration can include a class into a compilation unit.


Import declarations appear just after the package declaration and before the first type declaration.

You can have multiple import declarations in a compilation unit.

package declaration

import declaration 1
import declaration 2

class declaration 1

class declaration 2

other type declarations

import type

There are two types of import declarations:

  • Single-type import declaration
  • Import-on-demand declaration

Related Topics