| nolacoaster ( |
Hmm... good point. I'll probably add this. Here's what I cooked up:
This does have one problem though; it returns a Java Generics warning at the use of mapMe, "Type safety : A generic array of Pair<Integer,String> is created for a varargs parameter."
static <K,V> Map<K,V> mapMe(Pair<K,V>... pairs) {
Map<K,V> result = new HashMap<K,V>();
for( Pair<K,V> pair : pairs) {
result.put(pair.getP1(), pair.getP2());
}
return result;
}
static void useMapMe() {
Map<Integer,String> myMap = mapMe( Pair.pairMe(1, "Nels"),
Pair.pairMe(2, "William"));
}
This does have one problem though; it returns a Java Generics warning at the use of mapMe, "Type safety : A generic array of Pair<Integer,String> is created for a varargs parameter."