Unnamed Packages
A compilation unit that has no package declaration is part of an unnamed package.
Note that an unnamed package cannot have subpackages, since the syntax of a
package declaration always includes a reference to a named top level package.
As an example, the compilation unit:
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.
1)An implementation of the Java platform must support at least one unnamed
package; it may support more than one unnamed package but is not required to do
so. Which compilation units are in each unnamed package is determined by the
host system.
2In implementations of the Java platform that use a hierarchical file system for
storing packages, one typical strategy is to associate an unnamed package with
each directory; only one unnamed package is observable at a time, namely the one
that is associated with the “current working directory.” The precise meaning of
“current working directory” depends on the host system.
Unnamed packages are provided by the Java platform principally for convenience
when developing small or temporary applications or when just beginning
development.
A compilation unit that has no package declaration is part of an unnamed package.
Note that an unnamed package cannot have subpackages, since the syntax of a
package declaration always includes a reference to a named top level package.
As an example, the compilation unit:
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.
1)An implementation of the Java platform must support at least one unnamed
package; it may support more than one unnamed package but is not required to do
so. Which compilation units are in each unnamed package is determined by the
host system.
2In implementations of the Java platform that use a hierarchical file system for
storing packages, one typical strategy is to associate an unnamed package with
each directory; only one unnamed package is observable at a time, namely the one
that is associated with the “current working directory.” The precise meaning of
“current working directory” depends on the host system.
Unnamed packages are provided by the Java platform principally for convenience
when developing small or temporary applications or when just beginning
development.
0 comments:
Post a Comment