Package Members
The members of a package are its subpackages and all the top level
class types and top level interface types declared in all the compilation
units of the package.
For example, in the Java Application Programming Interface:
• The package java has subpackages awt, applet, io, lang, net, and util,
but no compilation units.
• The package 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 of a package is P, and Q is a subpackage of P,
then P.Q is the fully qualified name of the subpackage.
A package may not contain two member of the same name, or a compiletime
error results.
Here are some examples:
• Because the package java.awt has a subpackage image, it cannot (and does
not) contain a declaration of a class or interface type named image.
• If there is a package named mouse and a member 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.
• If 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 itself other than the prohibition against a package having a subpackage with the
same simple name as a top level type declared in that package. There is no
special access relationship 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.
The members of a package are its subpackages and all the top level
class types and top level interface types declared in all the compilation
units of the package.
For example, in the Java Application Programming Interface:
• The package java has subpackages awt, applet, io, lang, net, and util,
but no compilation units.
• The package 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 of a package is P, and Q is a subpackage of P,
then P.Q is the fully qualified name of the subpackage.
A package may not contain two member of the same name, or a compiletime
error results.
Here are some examples:
• Because the package java.awt has a subpackage image, it cannot (and does
not) contain a declaration of a class or interface type named image.
• If there is a package named mouse and a member 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.
• If 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 itself other than the prohibition against a package having a subpackage with the
same simple name as a top level type declared in that package. There is no
special access relationship 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.
0 comments:
Post a Comment