The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Interfaces and Packages

Summary of Creating and Using Packages

To create a package, put a type (class, interface, enum, or annotation) in it. To put a class or an interface into a package, put a package statement as the first statement in the source file for the class or the interface. The path name of the source and class file of a class or an interface mirrors the name of the package.

To use a class or an interface that's in a different package, you have three choices: (1) use the fully qualified name of the class or the interface, (2) import the class or the interface, or (3) import the entire package of which the class or the interface is a member.

You might have to set your class path so that the compiler and the interpreter can find the source and class files for your classes and interfaces.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.