map的遍历

Posted leeego-123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了map的遍历相关的知识,希望对你有一定的参考价值。

 

JDK8推荐使用

 

map.forEach((K, V) -> {
System.out.println("Key : " + K);
System.out.println("Value : " + V);
});

 

 

 foreach推荐使用

 

for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("Key : " + entry.getKey());
System.out.println("Value : " + entry.getValue());
}

 

 

不推荐使用

 

for (String key : map.keySet()) {
System.out.println("Key : " + key);
System.out.println("Value : " + map.get(key));
}

以上是关于map的遍历的主要内容,如果未能解决你的问题,请参考以下文章

Groovymap 集合 ( map 集合遍历 | 使用 map 集合的 find 方法遍历 map 集合 | 代码示例 )

CSP核心代码片段记录

将多个输出中的hls属性设置为单独的片段代码

RecyclerView holder中的Android Google Maps动态片段

java Map 怎么遍历

Map 遍历取值及jstl的取值