7
C H A P T E R
Packages
Good things come in small packages.
 Traditional proverb
J
AVA programs are organized as sets of packages. Each package has its own set
of names for types, which helps to prevent name conflicts. A type is accessible
( 6.6) outside the package that declares it only if the type is declared
public
.
The naming structure for packages is hierarchical ( 7.1). The members of a
package are class and interface types ( 7.6), which are declared in compilation
units of the package, and subpackages, which may contain compilation units and
subpackages of their own.
A package can be stored in a file system ( 7.2.1) or in a database ( 7.2.2).
Packages that are stored in a file system have certain constraints on the organiza 
tion of their compilation units to allow a simple implementation to find classes
easily. In either case, the set of packages available to a Java program is determined
by the host system, but must always include at least the three standard packages
java.lang
,
java.util
, and
java.io
 as specified in Chapters 20, 21, and 22. In
most host environments, the standard packages
java.applet
,
java.awt
, and
java.net
, which are not described in this specification, are also available to Java
programs.
A package consists of a number of compilation units ( 7.3). A compilation
unit automatically has access to all types declared in its package and also automat 
ically imports each of the types declared in the predefined package
java.lang
.
A compilation unit has three parts, each of which is optional:
A
package
 declaration ( 7.4), giving the fully qualified name ( 6.7) of the
package to which the compilation unit belongs
import
 declarations ( 7.5) that allow types from other packages to be
referred to using their simple names
Type declarations ( 7.6) of class and interface types
113






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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