7.1
Package Members
PACKAGES
For small programs and casual development, a package can be unnamed
( 7.4.2) or have a simple name, but if Java code is to be widely distributed, unique
package names should be chosen ( 7.7). This can prevent the conflicts that would
otherwise occur if two development groups happened to pick the same package
name and these packages were later to be used in a single program.
7.1 Package Members
A
package
can have members of either or both of the following kinds:
Subpackages of the package
Types declared in the compilation units ( 7.3) of the package
For example, in the standard 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 ( 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:
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 type
Button
in that package (which
then might be referred to as
mouse.Button
), then there cannot be any pack
age 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
.
114
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved