HashMap--EntrySet 泛型

 1 @Test
 2     public void test(){
 3         Map<String,Integer> myMap = new LinkedHashMap<String,Integer>();
 4         myMap.put("s1", 1);
 5         myMap.put("s2", 2);
 6         myMap.put("s3", 3);
 7         
 8         Set<Map.Entry<String, Integer>> entrySet = myMap.entrySet();
 9         for(Map.Entry<String, Integer> e:entrySet){
10             String key = e.getKey();
11             int  value = e.getValue();
12             System.out.println(key+":"+value);
13         }
14         
15     }

 

posted @ 2014-04-08 15:46  一路向北中  阅读(328)  评论(0编辑  收藏  举报