Java遍历Map的方法,使用entrySet()效率是keySet()的2倍
Map
maps = new HashMap
();
//用while
Iterator
> it = maps.entrySet().iterator();
while (it.hasNext()) {
Map.Entry
m = it.next(); String key = m.getKey(); String value = m.getValue(); } //用foreach for (Map.Entry
m : maps.entrySet()) { String key = m.getKey(); String value = m.getValue(); }