Packages

When you start creating a large number of classes for a program, having a way to organize them becomes important. A clutter of class files is not unlike how your hard drive would look without subdirectories or folders. Imagine if all the files on your hard drive were placed in a single folder. You would have thousands of files without any obvious associations among them and you would have to make sure that no two files had the same name.

Class files without any organization cause similar problems. To overcome this, Java has a system called packages. A package contains a group of classes just as a subdirectory contains a group of files. You have already seen how a number of packages are used in the Java API. For example, java.awt and ...

Get Special Edition Using Java 2 Standard Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.