Title: Importing packages and package members
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Importing packages and package members

The import statement is used to access the code in a package or package member.

To import an entire package, the wildcard character (*) is used:

import <package-name>.*;

Java will determine which package members are actually needed in the class and import only those.

Note that the wildcard character only applies to package members, not other packages that have similar names.  For example, statement import java .awt.*; imports all members of package java.awt, but not packages java.awt.color, java.awt.font, etc.

To import a package member, its name is used:

import <package-name>.<package-member>;

For more information, see:

Using Package Members