A package can have members of either or both of the following kinds:
For example, in the standard Java Application Programming Interface:
java has subpackages awt, applet, io, lang, net, and util, but no compilation units.
java.awt has a subpackage named image, as well as a number of compilation units containing declarations of class and interface types.
If the fully qualified name (§6.7) of a package is P, and Q is a subpackage of P,
then P.Q is the fully qualified name of the subpackage.
The subpackages of package java named lang, util, and io (whose fully qualified package names are therefore java.lang, java.util, and java.io) are a standard part of every Java implementation and are specified in Chapters 20, 21, and 22. Many Java implementations will include the entire set of java packages defined in the series of books The Java Application Programming Interface.
A package may not contain a type declaration and a subpackage of the same name, or a compile-time error results. Here are some examples:
java.awt has a subpackage image, it cannot (and does not) contain a declaration of a class or interface type named image.
mouse and a type Button in that package (which then might be referred to as mouse.Button), then there cannot be any package with the fully qualified name mouse.Button or mouse.Button.Click.
COM.Sun.java.jag is the fully qualified name of a type, then there cannot be any package whose fully qualified name is either COM.Sun.java.jag or COM.Sun.java.jag.scrabble.
The hierarchical naming structure for packages is intended to be convenient for organizing related packages in a conventional manner, but has no significance in the Java language itself other than the prohibition against a package having a subpackage with the same simple name as a type declared in that package. There is no special access relationship in the Java language between a package named oliver and another package named oliver.twist, or between packages named evelyn.wood and evelyn.Waugh. For example, the code in a package named oliver.twist has no better access to the types declared within package oliver than code in any other package.