An import declaration allows a type declared in another package to be referred to
by a simple name (§6.2) that consists of a single identifier. Without the use of an
appropriate import
declaration, the only way to refer to a type declared in another
package is to use its fully qualified name (§6.7).
ImportDeclaration:
SingleTypeImportDeclaration
TypeImportOnDemandDeclaration
A single-type-import declaration (§7.5.1) imports a single type, by mentioning its fully qualified name. A type-import-on-demand declaration (§7.5.2) imports all the public
types of a named package as needed.
An import
declaration makes types available by their simple names only within the compilation unit that actually contains the import
declaration. The scope of the name(s) it introduces specifically does not include the package
statement, other import
statements in the current compilation unit, or other compilation units in the same package. Please see §7.5.4 for an illustrative example.