轉]Java中HashMap遍歷的兩種方式原文地址: http://www.javaweb.cc/language/java/032291.shtml第一種: 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(); } 效率高,之後必定要使用此種方式!