Monday, July 5, 2010

Defining a Package

To define a package the package command is included as the first statement in a Java source file. Any classes declared within that file will belong to the specified package. The package statement defines a name space in which classes are stored.

package pakage_name;

/* If you omit the package statement, the class names are put into the default package, which has no name.*/

Java uses file system directories to store packages. For example, the .class files for any classes you declare to be part of MyPackage must be stored in a directory called MyPackage.

No comments:

Post a Comment