1.使用entries来遍历,如果遍历的map是一个空值,循环会抛出NUllPointerException
for(Map.Entry<String, String> entry : map.entrySet()) {
System.out.print("Key = " + entry.getKey() + ",value=" + entry.getValue());
}
2.使用keySet
for(String key : map.keySet()){
System.out.print("Key = "+key+"value = "+map.get(key));
}