话不多说,看代码和效果
public static List
测试:
public static void main(String[] args) {
Map msp = new HashMap();
List> list = new ArrayList>();
List> listMap = new ArrayList>();
Map map1 = new HashMap();
map1.put("id", "1123");
map1.put("name", "张三");
Map map2 = new HashMap();
map2.put("id", "2");
map2.put("name", "李四");
Map map3 = new HashMap();
map3.put("id", "1123");
map3.put("name", "王五");
Map map4 = new HashMap();
map4.put("id", "3");
map4.put("name", "赵六");
list.add(map1);
list.add(map2);
list.add(map3);
list.add(map4);
System.out.println("初始数据:" + list.toString());
System.out.println("去重之后:" + removeRepeatMapByKey(list,"id"));
}
结果:
初始数据:[{name=张三, id=1123}, {name=李四, id=2}, {name=王五, id=1123}, {name=赵六, id=3}]
去重之后:[{name=李四, id=2}, {name=赵六, id=3}, {name=张三, id=1123}]
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对考高分网的支持。如果你想了解更多相关内容请查看下面相关链接



