Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
用HashMap的匿名内部类Entry遍历这种方式比较快,只遍历了一次 ,得到HashMap的Entry,就得到了key和value |
|