- //方法一
- Set<String> set = map.keySet();
- for (String s:set) {
- System.out.println(s+","+map.get(s));
- }
- //方法二
- Set<Map.Entry<String, String>> entryseSet=map.entrySet();
- for (Map.Entry<String, String> entry:entryseSet) {
- System.out.println(entry.getKey()+","+entry.getValue());
- }
Java中遍历Map的两种方法:keySet和entrySet
最新推荐文章于 2024-04-18 05:41:33 发布