10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.1 Package Members PACKAGES<br />

154<br />

7.1 Package Members<br />

<strong>The</strong> members of a package are its subpackages and all the top level (§7.6)<br />

class types (§8) and top level interface types (§9) declared in all the compilation<br />

units (§7.3) of the package.<br />

For example, in the <strong>Java</strong> Application Programming Interface:<br />

• <strong>The</strong> package java has subpackages awt, applet, io, lang, net, and util,<br />

but no compilation units.<br />

• <strong>The</strong> package java.awt has a subpackage named image, as well as a number<br />

of compilation units containing declarations of class and interface types.<br />

If the fully qualified name (§6.7) of a package is P, and Q is a subpackage of P,<br />

then P.Q is the fully qualified name of the subpackage.<br />

A package may not contain two members of the same name, or a compiletime<br />

error results.<br />

Here are some examples:<br />

• Because the package java.awt has a subpackage image, it cannot (and does<br />

not) contain a declaration of a class or interface type named image.<br />

• If there is a package named mouse and a member type Button in that package<br />

(which then might be referred to as mouse.Button), then there cannot be any<br />

package with the fully qualified name mouse.Button or mouse.Button.Click.<br />

• If com.sun.java.jag is the fully qualified name of a type, then there cannot<br />

be any package whose fully qualified name is either com.sun.java.jag or<br />

com.sun.java.jag.scrabble.<br />

<strong>The</strong> hierarchical naming structure for packages is intended to be convenient<br />

for organizing related packages in a conventional manner, but has no significance<br />

in itself other than the prohibition against a package having a subpackage with the<br />

same simple name as a top level type (§7.6) declared in that package. <strong>The</strong>re is no<br />

special access relationship between a package named oliver and another package<br />

named oliver.twist, or between packages named evelyn.wood and evelyn.waugh.<br />

For example, the code in a package named oliver.twist has no<br />

better access to the types declared within package oliver than code in any other<br />

package.<br />

DRAFT

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!