Java中怎么遍历map中value值

//两种方法,有问题,给我发百度消息
 public static void main(String[] args){
  Map map = new HashMap();
  map.put("id1", "wang");
  map.put("id2", "sheng");
  
  //方法一
  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)