Creating a Package

package com.timothyfisher.book;

In a large application or library, Java classes are usually organized into packages. To put a class into a package, you simply include a package statement, such as the one shown in this phrase, at the beginning of the class file. The package statement must be the first non-comment line of a class file. The example in this phrase would assign the class contained in the file to the package com.timothyfisher.book.

The package name of a class becomes a part of its full name. For example, if we had a class named MathBook in the com.timothyfisher.book package, the fully specified class name would be com.timothyfisher.book.MathBook. Package names also dictate the directory structure in which the class ...

Get Java™ Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.