1.利用distinct去重 并保持数组的顺序
ArrayList<Integer> list = new ArrayList(); list.add(7); list.add(5); list.add(9); list.add(8); list.add(8); list.add(8); list.add(2); list.add(3); List<Integer> collect = list.stream().distinct().collect(Collectors.toList()); System.out.println(collect);
输出:
[7, 5, 9, 8, 2, 3]
标签:distinct,ArrayList,list,特性,collect,add,Java8 From: https://www.cnblogs.com/pijunqi/p/16935479.html