//方法一
Set set = map.keySet();
for (String s:set) {
System.out.println(s+","+map.get(s));
}
//方法二
Set> entryseSet=map.entrySet();
for (Map.Entry entry:entryseSet) {
System.out.println(entry.getKey()+","+entry.getValue());
}
//方法一
Set set = map.keySet();
for (String s:set) {
System.out.println(s+","+map.get(s));
}
//方法二
Set> entryseSet=map.entrySet();
for (Map.Entry entry:entryseSet) {
System.out.println(entry.getKey()+","+entry.getValue());
}
本文标题:Java中遍历Map的两种方法:keySet和entrySet
本文链接:https://www.haomeiwen.com/subject/wvdiuttx.html
网友评论