1、遍历map集合的两种方法
方法1:先获取所有key,然后根据key去map中取value
Set<String> keySet = map.keySet();
for(String key:keySet){
Integer value = map.get(key);
System.out.println(key + "," +value)
}
方法2:先获取所有Entry<String,Integer>
Set<Entry<String,Integer>> entrySet = map.entrySet();
for(Entry<String,Integer> ent:entrySet){
sysout(ent.getKey() + "," + ent.getValue());
}