Java Reference
In-Depth Information
It is a compile-time error if the named type is not accessible (§ 6.6 ).
The Identifier must name at least one static member of the named type. It is a compile-time
error if there is no static member of that name, or if all of the named members are not ac-
cessible.
It is permissible for one single-static-import declaration to import several fields or types
with the same name, or several methods with the same name and signature.
If a single-static-import declaration imports a type whose simple name is n , and the com-
pilation unit also declares a top level type (§ 7.6 ) whose simple name is n , a compile-time
error occurs.
If a compilation unit contains both a single-static-import declaration that imports a type
whose simple name is n , and a single-type-import declaration (§ 7.5.1 ) that imports a type
whose simple name is n , a compile-time error occurs.
7.5.4. Static-Import-on-Demand Declarations
A static-import-on-demand declaration allows all accessible static members of a named
type to be imported as needed.
StaticImportOnDemandDeclaration:
import static TypeName . * ;
The TypeName must be the canonical name (§ 6.7 ) of a class type, interface type, enum
type, or annotation type.
It is a compile-time error if the named type is not accessible (§ 6.6 ).
Two or more static-import-on-demand declarations in the same compilation unit may name
the same type; the effect is as if there was exactly one such declaration.
Two or more static-import-on-demand declarations in the same compilation unit may name
the same member; the effect is as if the member was imported exactly once.
It is permissible for one static-import-on-demand declaration to import several fields or
types with the same name, or several methods with the same name and signature.
If a compilation unit contains both a static-import-on-demand declaration and a type-
import-on-demand declaration (§ 7.5.2 ) that name the same type, the effect is as if the static
member types of that type (§ 8.5 , § 9.5 ) were imported only once.
Search WWH ::




Custom Search