Packages are class libraries that may beimported
and used in building programs. They are included at the beginning of the program or class file, using statement similar to the following:import java.applet.Applet; import java.awt.*; // window and drawing toolsVariables and methods included in the package classes may be used as if they were included in the program code. But, again, in doing so, the programmer must be conscious of the class hierarchy and the propagation of messages up and down the hierarchy. In the discussions that follow, this point will be emphasized repeatedly.
Several frequently used packages include the following:
Java.lang contains the basic classes for the Java language. Java.applet contains the classes for applets. And java.awt contains classes for creating windows, graphic operations, capturing user events, etc.