Multiple Type ParametersIf you look at the API documentation for java.util.List and java.util.ArrayList, you will see that they are declared as List<E> and ArrayList<E>, respectively. The <E> is known as the type parameter list. The List interface and ArrayList class declarations each contain a single type parameter in the type parameter list. Therefore you must supply a single bind type when using List or ArrayList in your code.[1]
The class HashMap represents a collection of key-value pairs. A key can be of one type and the value could be another. For example, you might store an appointment book in a HashMap, where the key is a Date and the value is a String description of an event occurring on that date.
The Map interface and HashMap class are declared as Map<K,V> and HashMap<K,V>, respectively. You must supply two bind types when using theseone for the key (K) and one for the value (V). |
Wednesday, October 14, 2009
Multiple Type Parameters
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment