首页 > 其他 > 详细

map的遍历

时间:2019-12-19 17:38:41      阅读:105      评论:0      收藏:0      [点我收藏+]

 

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的遍历

原文:https://www.cnblogs.com/leeego-123/p/12069053.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!