map的遍历
分别是遍历键值对和遍历键,遍历键是通过键取出对应的值
//遍历1
Set<Entry<String, String>> set = map.entrySet();
//遍历键值对
for(Map.Entry<String, String> k: set) {
//键
String key = k.getKey();
//值
String value = k.getValue();
System.out.println(key+":"+value);
}
//遍历2
//获取键的集合
Set<String> keySet = map.keySet();
for(String k:keySet) {
String value = map.get(k);
System.out.println(k+":"+value);
}