本帖最后由 熊志伟 于 2013-12-23 17:27 编辑
两种:Set keySet()和Set entrySet()
Set keySet = map.keySet();
Iteratorit = keySet.iterator();
while(it.hasNext()){
Objectkey = it.next(); Objectvalue = map.get(key); System.out.println(key+":"+value); }
Set entrySet = map.entrySet(); Iteratorit = entrySet.iterator(); while(it.hasNext()){ Map.Entry me = (Map.Entry)it.next(); System.out.println(me.getKey()+"::::"+me.getValue()); }
|