首页 > 代码库 > java遍历Map

java遍历Map

//方法一  
Set<String> keys = map.keySet();   
for (String key:keys) {  
   System.out.println(key+","+map.get(key));  
}  

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

  

java遍历Map