Professional Documents
Culture Documents
corresponding to the generic type’s formal type parameters For example, List<String> (read
“list of string”) is a parameterized type representing a list whose elements are of type String.
(String is the actual type parameter corresponding to the formal type parameter E.)
Generics Introduction continued….
You don’t get an error until you try to retrieve the coin from the stamp collection:
choiceArray = choices.toArray();
If you try to compile this class, you’ll get this error message:
converted to T[]
choiceArray = choices.toArray();
where T is a type-variable:
• If the user of a class has to think about wildcard types, there's probably something
wrong with its API.
• For Comparable<T> and Comparator<T>, its better to use as Comparable<? super T>
and Comparator<? super T>; The comparable T consumes T instances and produces
integers indicating order relations.
Item 7