Java Reference
In-Depth Information
PackageOrTypeName . Identifier
AmbiguousName:
Identifier
AmbiguousName . Identifier
The use of context helps to minimize name conflicts between entities of different
kinds. Such conflicts will be rare if the naming conventions described in § 6.1 are fol-
lowed. Nevertheless, conflicts may arise unintentionally as types developed by differ-
ent programmers or different organizations evolve. For example, types, methods, and
fields may have the same name. It is always possible to distinguish between a meth-
od and a field with the same name, since the context of a use always tells whether a
method is intended.
6.5.1. Syntactic Classification of a Name According to Context
A name is syntactically classified as a PackageName in these contexts:
• In a package declaration (§ 7.4 )
• To the left of the “ . ” in a qualified PackageName
A name is syntactically classified as a TypeName in these contexts:
• In a single-type-import declaration (§ 7.5.1 )
• To the left of the “ . ” in a single-static-import declaration (§ 7.5.3 )
• To the left of the “ . ” in a static-import-on-demand declaration (§ 7.5.4 )
• To the left of the “ < ” in a parameterized type (§ 4.5 )
• In a type argument list (§ 4.5.1 ) of a parameterized type
• In an explicit type argument list in a method or constructor invocation
• In an extends clause in a type variable declaration (§ 8.1.2 )
• In an extends clause of a wildcard type argument (§ 4.5.1 )
• In a super clause of a wildcard type argument (§ 4.5.1 )
• In an extends clause in a class declaration (§ 8.1.4 )
• In an implements clause in a class declaration (§ 8.1.5 )
• In an extends clause in an interface declaration (§ 9.1.3 )
• After the “ @ ” sign in an annotation (§ 9.7 )
• As a Type (or the part of a Type that remains after all brackets are deleted) in any
of the following contexts:
Search WWH ::




Custom Search