JavaList去重-创新互联

Java List 去重
  • 利用 Set的性质

    成都创新互联"三网合一"的企业建站思路。企业可建设拥有电脑版、微信版、手机版的企业网站。实现跨屏营销,产品发布一步更新,电脑网络+移动网络一网打尽,满足企业的营销需求!成都创新互联具备承接各种类型的网站建设、成都做网站项目的能力。经过10年的努力的开拓,为不同行业的企事业单位提供了优质的服务,并获得了客户的一致好评。
    public static void main(String[] args) {Setset = new HashSet<>();
            Listlist = new LinkedList<>();
            Map map1 = new HashMap();
            map1.put("name","zhangsan");
            Map map2 = new HashMap();
            map2.put("name","zhangsan");
            Map map3 = new HashMap();
            map3.put("name","lisi");
            list.add(map1);
            list.add(map2);
            list.add(map3);
    
            for (int i = 0; i< list.size(); i++) {set.add(list.get(i));
            }
    
            set.forEach(i->{System.out.println(i);
            });
  • 新建一个新的List,把结果放在新的List中

    public static void main(String[] args) {ListnewList = new ArrayList<>();
            Listlist = new LinkedList<>();
            Map map1 = new HashMap();
            map1.put("name","zhangsan");
            Map map2 = new HashMap();
            map2.put("name","zhangsan");
            Map map3 = new HashMap();
            map3.put("name","lisi");
            list.add(map1);
            list.add(map2);
            list.add(map3);
    
            for (int i = 0; i< list.size(); i++) {if (!newList.contains(list.get(i))){newList.add(list.get(i));
                }
            }
    
            newList.forEach(i->{System.out.println(i);
            });

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


网页标题:JavaList去重-创新互联
分享链接:http://lszwz.com/article/ihiie.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款