Previous | Next | Trail Map | The Java Development Environment | Table of Contents


Creating and Using Packages

The Java development environment includes several packages of reusable classes. These packages are discussed at length in the previous lesson Package Tour . The Java language provides a way for you to create packages of classes and interfaces as well.

Roll Your Own Packages

Packages are groups of related classes and interfaces and provide convenient a mechanism for managing a large set of classes and interfaces and avoiding naming conflicts.

Using the package statement you can create a package and indicate that certain classes are part of that package.

Using Objects and Classes from Other Packages

To use objects that are contained in package, whether it's a package provided with the development environment, or one you've created, you need to import the package.

Clarifying Object and Class Names

When two classes in two different packages have the same name, you have to prepend the package name to the class name.

Directory Structure

The interpreter expects the directory structure of classes to be the same as the package hierarchy.


Previous | Next | Trail Map | The Java Development Environment | Table of Contents