map 遍历 多种方法

Map regionMap = statReportService.getRegionList(); for (Iterator iter=regionMap.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();
------------------------------------

Iterator it=map.keySet().iterator();   
while(it.hasNext()) {   
      String key;   
      String value;   
      key=it.next().toString();   
      value=map.get(key);   
      System.out.println(key+" = "+value);   


------------------------------------
Set set = map.entrySet();        
Iterator i = set.iterator();        
while(i.hasNext()){     
      Map.Entry<String, String> entry=(Map.Entry<String, String>)i.next();   
      System.out.println(entry.getKey()+" = "+entry.getValue());   
}
------------------------------------

for(Map.Entry<String, String> entry:map.entrySet())  {   
    System.out.println(entry.getKey()+" = "+entry.getValue());   
}

你可能感兴趣的:(map)