Java Reference
In-Depth Information
Pair<String,String>
Examples of incorrect invocations of a generic type:
Vector<int> is illegal, as primitive types cannot be type arguments.
Pair<String> is illegal, as there are not enough type arguments.
Pair<String,String,String> is illegal, as there are too many type arguments.
A parameterized type may be an invocation of a generic class or interface which is
nested. For example, if a non-generic class C has a generic member class D<T> , then
C.D <Object> is a parameterized type. And if a generic class C<T> has a non-gener-
ic member class D , then the member type C <String>. D is a parameterized type, even
though the class D is not generic.
Two parameterized types are provably distinct if either of the following conditions hold:
• They are invocations of distinct generic type declarations.
• Any of their type arguments are provably distinct.
4.5.1. Type Arguments and Wildcards
Type arguments may be either reference types or wildcards. Wildcards are useful in situ-
ations where only partial knowledge about the type parameter is required.
TypeArguments:
< TypeArgumentList >
TypeArgumentList:
TypeArgument
TypeArgumentList , TypeArgument
TypeArgument:
ReferenceType
Wildcard
Wildcard:
? WildcardBounds opt
WildcardBounds:
extends ReferenceType
super ReferenceType
Search WWH ::




Custom Search