| 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. |