今天工作中需要使用HashMap来排重,然后将最终Value集插入List
List.addAll()方法不支持HashMap,所以只好自己coding
解决办法
Set<Map.Entry<String,Department>> entry =departmentHashMap.entrySet();
for(Map.Entry<String,Department> e:entry){
departmentList.add(e.getValue());
}
使用hashMap.entrySet()方法
然后foreach遍历存入List