Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从列表<;地图<;字符串,对象>&燃气轮机;要删除java 8中HashMap中某个属性的重复值,_Java - Fatal编程技术网

从列表<;地图<;字符串,对象>&燃气轮机;要删除java 8中HashMap中某个属性的重复值,

从列表<;地图<;字符串,对象>&燃气轮机;要删除java 8中HashMap中某个属性的重复值,,java,Java,附加代码段 List<Map<String,A>> listm=new ArrayList<>(); Map<String,A> map=new HashMap<>(); A a1=new A(); a1.setAge("30"); a1.setName("Mani"); map.put("1", a1); A a2 =new A(); a2.setAge("31"); a2.setName("sasi"); Map<Stri

附加代码段

List<Map<String,A>> listm=new ArrayList<>();

Map<String,A> map=new HashMap<>();
A a1=new A();
a1.setAge("30");
a1.setName("Mani");
map.put("1", a1);

A a2 =new A();
a2.setAge("31");
a2.setName("sasi");
Map<String,A> map1=new HashMap<>();
map1.put("2", a2);

A a3=new A();
a3.setAge("31");
a3.setName("Naveen");
Map<String,A> map2=new HashMap<>();

map2.put("3", a3);
listm.add(map);
listm.add(map1);
listm.add(map2);

List<Map<String, A>>    list = listH.stream()
               .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))
               .entrySet()
               .stream()
               .filter(e -> e.getValue() == 1)
               .map(Map.Entry::getKey)
               .collect(Collectors.toList());
List listm=new ArrayList();
Map Map=newhashmap();
a1=新的A();
a1.设置(“30”);
a1.设置名称(“Mani”);
地图放置位置(“1”,a1);
a2=新的A();
a2.设置(“31”);
a2.设置名称(“sasi”);
Map map1=新的HashMap();
地图1.放置(“2”,a2);
a3=新的A();
a3.设置(“31”);
a3.设置名称(“Naveen”);
Map map2=新的HashMap();
地图2.放置(“3”,a3);
添加(映射);
列表M.add(地图1);
列表m.add(map2);
List=listH.stream()
.collect(Collectors.groupingBy(Function.identity(),LinkedHashMap::new,Collectors.counting())
.entrySet()
.stream()
.filter(e->e.getValue()==1)
.map(map.Entry::getKey)
.collect(Collectors.toList());

上面的lambda表达式没有删除重复的年龄对象,响应应该只有2条记录。其中一个是组30和组31,因为组31是重复的

更改参数过滤打开:

.filter(entry-> Collections.frequency(listH.values(), entry.getValue()) > 1)

此代码未编译-什么是
listH
?为什么有
Map
s的
List
?每个
Map
只有一个条目。