7.5.2
Type Import on Demand Declaration
PACKAGES
Note that an import statement cannot import a subpackage, only a type. For
example, it does not work to try to import
java.util
 and then use the name
util.Random
 to refer to the type
java.util.Random
:
import java.util;
//
incorrect: compile time error
class Test { util.Random generator; }
7.5.2   Type Import on Demand Declaration
A
type import on demand declaration
 allows all
public
 types declared in the
package named by a fully qualified name to be imported as needed.
TypeImportOnDemandDeclaration:
import
PackageName
 . * ;
It is a compile time error for a type import on demand declaration to name a
package that is not accessible ( 6.6), as determined by the host system ( 7.2).
Two or more type import on demand declarations in the same compilation unit
may name the same package; the effect is as if there were exactly one such decla 
ration. It is not a compile time error to name the current package or
java.lang
 in
a type import on demand declaration, even though they are already imported; the
duplicate type import on demand declaration is ignored.
The example:
import java.util.*;
causes the simple names of all
public
 types declared in the package
java.util
to be available within the class and interface declarations of the compilation unit.
Thus, the simple name
Vector
 refers to the type
Vector
 in the package
java.util
 in all places where it is not hidden ( 6.3) by a single type import dec 
laration of a type whose simple name is
Vector
; by a type named
Vector
 and
declared in the package to which the compilation unit belongs; or by a declaration
of a field, parameter, or local variable named
Vector
. (It would be unusual for any
of these conditions to occur.)
7.5.3   Automatic Imports
Each compilation unit automatically imports each of the
public
type names
declared in the predefined package
java.lang
, as if the declaration:
import java.lang.*;
appeared at the beginning of each compilation unit, immediately following any
package
 statement.
122






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