List a = new ArrayList<>(32);
a.add(1);
a.add(2);
a.add(3);
List b = new ArrayList<>(32);
b.add(2);
b.add(3);
b.add(3);
1.並集
a.addAll(b);
運行結果:1,2,3,2,3,3
2.無重復並集
a.removeAll(b);
a.addAll(b);
運行結果:1,2,3,3
3.交集
a.retainAll(b);
運行結果: 2,3
4.差集
a.removeAll(b);
運行結果:1
5,去重復(JDK8特性)
List newList = b.stream().distinct().collect(Collectors.toList());
運行結果:2,3
