代码语言:javascript复制
HashMap<String,String> map= new HashMap<>();
map.put("dsadf","张三");
map.put("vdsfa","李四");
map.put("dsadv","王五");
map.put("dasda","李四");
map.put("djgdf","李五");
map.put("ngsdf","李四");
System.out.println("提取前:" map);
HashMap<String, String> mapnew = new HashMap<>();
HashMap<String, String> mapnew2 = new HashMap<>();
map.forEach((k,v)->{
if(!mapnew.containsValue(v)){
mapnew.put(k,v);
}else{
mapnew2.put(k,v);
}
});
System.out.println("不重复的值:" mapnew);
System.out.println("重复的值:" mapnew2);