List字符串數組如何去重

個人資源與分享網站:http://xiaocaoshare.com/

public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        List<String[]> list=new ArrayList<String[]>();
        String[] str1= {"僑香公寓;7棟;13;1310", "HB170700068", "方園", "18565730881", "申海平", "18676362390", "租客需求"};
        String[] str2= {"僑香公寓;7棟;13;1310", "HB170700068", "方園", "18565730881", "申海平", "18676362390", "租客需求"};
        list.add(str1);
        list.add(str2);
        list.stream()
                .collect(
                        Collectors.collectingAndThen(
                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(x -> x[0] + x[1]+x[2]+x[3]+x[4]+x[5]+x[6]))),
                                ArrayList::new
                        )
                );

        
        list.stream().forEach(System.out::println);
        
        
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章