1 Map map = new HashMap(); 2 3 for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) { 4 5 Map.Entry entry = (Map.Entry) iter.next(); 6 7 Object key = entry.getKey(); //得键 8 9 Object val = entry.getValue(); //得值 10 11 } 12 13 或者: 14 15 Map map = new HashMap(); 16 17 for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { 18 19 Object key = iter.next(); //得键 20 21 Object val = map.get(key); //得值 22 23 }
时间: 2024-10-13 17:11:04