Java Reference
In-Depth Information
by the annotations on the package. While the file could technically contain the source
code for one or more package-private (default-access) classes, it would be very bad
form.
It is recommended that package-info.java , if it is present, take the place of package.html for
javadoc and other similar documentation generation systems. If this file is present, the
documentation generation tool should look for the package documentation comment
immediately preceding the (possibly annotated) package declaration in package-info.java .
In this way, package-info.java becomes the sole repository for package-level annotations
and documentation. If, in future, it becomes desirable to add any other package-level
information, this file should prove a convenient home for this information.
7.4.2. Unnamed Packages
A compilation unit that has no package declaration is part of an unnamed package .
Unnamed packages are provided by the Java SE platform principally for convenience when
developing small or temporary applications or when just beginning development.
Note that an unnamed package cannot have subpackages, since the syntax of a package de-
claration always includes a reference to a named top level package.
As an example, the compilation unit:
Click here to view code image
class FirstCall {
public static void main(String[] args) {
System.out.println("Mr. Watson, come here. "
+ "I want you.");
}
}
defines a very simple compilation unit as part of an unnamed package.
An implementation of the Java SE platform must support at least one unnamed package; it
may support more than one unnamed package but is not required to do so. Which compila-
tion units are in each unnamed package is determined by the host system.
In implementations of the Java SE platform that use a hierarchical file system for stor-
ing packages, one typical strategy is to associate an unnamed package with each dir-
ectory; only one unnamed package is observable at a time, namely the one that is as-
sociated with the “current working directory”. The precise meaning of “current work-
ing directory” depends on the host system.
Search WWH ::




Custom Search