Map遍历的方式有很多种,但是哪种是最高效的遍历方式呢?
最高效率遍历方式
Map<String, String> map = new HashMap<>();
map.put("a", "张三");
map.put("b", "李四");
map.put("c", "王五");
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}