- Map map=new HashMap();
- map.put("jessica",100);
- map.put("tom",200);
- map.put("den",300);
- Set<Entry<Integer, String>> set = map.entrySet() ;
- for ( Entry per : set) {
- System.out.println(per.getKey() + ":" + per.getValue());
- }
复制代码
这段代码中Entry<Integer, String>为什么可以这么写,
而如果在创建map时写Map<String,Integer> map又会报错,
提示应该写成Entry<String, Integer> |
|