1 List<String> list = new ArrayList<>();
2
3 list.add("111");
4 list.add("111");
5 list.add("aaa");
6 list.add("AAA");
7 list.add("aaa");
8 list.add("差异项");
9 list.add("差异项");
10
11 // 不排序
12 List<String> newList = new ArrayList<>(new HashSet<>(list));
13
14 // 字母顺序排序
15 List<String> newList = new ArrayList<>(new TreeSet<>(list));
16
17 // java8 新特性stream去重
18 List<String> newList = list.stream().distinct().collect(Collectors.toList());
// 分组
Map<Integer, List<Apple>> groupBy = appleList.stream().collect(Collectors.groupingBy(Apple::getId));
// 过滤出符合条件的数据
List<Apple> filterList = appleList.stream().filter(a -> a.getName().equals("香蕉")).collect(Collectors.toList());