美文网首页
map的两种遍历

map的两种遍历

作者: 就叫basi | 来源:发表于2019-12-11 13:58 被阅读0次

Map<String, Customer> customerMap = new HashMap<>();

//遍历entrySet
for (Map.Entry<String,Customer> m : customerMap.entrySet()){
m.getValue();//value值
m.getKey();key值
}

//遍历keySet
for (String s : customerMap.keySet()){
customerMap.get(s);//value值
}

vans.png

相关文章

网友评论

      本文标题:map的两种遍历

      本文链接:https://www.haomeiwen.com/subject/dumogctx.html