Package
 
Importing Packages
 
The import statement enables us to import classes from other packages into a compilation unit. We can import individual classes or entire packages of classes at the same time if we want.
 
The syntax for the import statement follows:
import Identifier;
 
Identifier is the name of the class or package of classes we are importing.
 
Other Example:
import java.awt.Color;
import java.awt.*;
 
The first statement imports the specific class Color, which is located in the java.awt package. The second statement imports all the classes in the java.awt package.
 
Note that the following statement doesn't work:
import java.*;
 
This statement doesn't work because we can't import nested packages with the * specification. This wildcard works only when importing all the classes in a particular package, which is still very useful.
 
 
There is one other way to import objects from other packages: explicit package referencing.
 
By explicitly referencing the package name each time we use an object, we can avoid using an import statement. Using this technique, the declaration of the color member variable look like this:
java.awt.Color color;