Map映射的main方法里面,到底该怎么样的new()一个对象
RT
public class MapTest2 {
public Map<String, Integer> putkey(String string, Integer integer) {
Map<String, Integer> tempMap = new HashMap<String, Integer>();
tempMap.put("a", 1);
tempMap.put("b", 2);
tempMap.put("c", 3);
return tempMap;
}
public static void main(String[] args) {
Map map = new HashMap();
MapTest2 mt = new MapTest2();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
System.out.println(" key " + key + " value " + value);
}
}
}