HashMap遍历的两种方式
方法一
1 Map map = new HashMap();
2 Iterator iter = map.entrySet().iterator();
3 while (iter.hasNext()) {
4 Map.Entry entry = (Map.Entry) iter.next();
5 Object key = entry.getKey();
6 Object val = entry.getValue();
7 }
方法二
1 Map map = new HashMap();
2 Iterator iter = map.keySet().iterator();
3 while (iter.hasNext()) {
4 Object key = iter.next();
5 Object val = map.get(key);
6 }
方法一较方法二效率高