«^»
6.1. Package declarations

By default, a class/interface declaration belongs to the default package. And .class files are stored in the current directory.

It is useful to be able to group related classes/interfaces together. And for this, Java has the concept of a package.

You can use a package declaration to indicate that a class/interface belongs to a particular package. For example, suppose you have a file containing the text of a class called Date and that you want it to belong to a package called dateutils. You just need to insert a package declaration at the start of the file:

package dateutils;
Any class/interface declaration that contains this line belongs to this package. The .class files associated with these files of source code must appear in a directory called dateutils. And any client that wishes to use this class could use an import declaration, such as:
import dateutils.Date;

If instead some class/interface declarations each have a package declaration that takes the form:

package utils.dateutils;
then the .class files should be in a subdirectory called dateutils that is itself in a directory called utils. Any client that wishes to use the class called Date belonging to this package could use the import declaration:
import utils.dateutils.Date;