TreeMap<String, String> map=new TreeMap<String, String>();
map.put("1", "a");
map.put("2", "b");
map.put("3", "c");
Set<String> set=map.keySet();
Iterator it=set.iterator();
while (it.hasNext()) {
String str = it.next();
System.out.println(str+map.get(str));
}
调试时,出错,找了很久,原来是Iterator没加泛型。
|
|