遍历Map

方法1:

for (Map.Entry<String, Student> entry : stuMap.entrySet()) {  

         stuStr = entry.getKey();   

         stu = entry.getValue();  

     }  

方法2:

 Iterator<Map.Entry<String,Student>> it = stuMap.entrySet().iterator();   

        while (it.hasNext()) {  

         Map.Entry<String,Student> entry = it.next();  

         stuStr = entry.getKey();   

         stu = entry.getValue();  

  }  

方法3:

for (String stuKey : stuMap.keySet()) {  

          stuStr = stuKey;   

          stu = stuMap.get(stuKey);  

     }  

posted @ 2018-01-07 12:57  prettyGff  Views(137)  Comments(0)    收藏  举报