1.交集
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.intersection(list2, list1));
2.差集
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.subtract(list1, list2));
System.out.println(CollectionUtils.subtract(list2, list1));
3.并集
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.union(list2, list1));
4.交集的补集
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.disjunction(list2, list1));
5.集合元素是否相等
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.isEqualCollection(list2, list1));
List<Integer> list3=Arrays.asList(1,2,3);
List<Integer> list4=Arrays.asList(3,2,1);
System.out.println(CollectionUtils.isEqualCollection(list3, list4));
6.集合判空
List<Integer> list1=Arrays.asList(1,2,3);
System.out.println(CollectionUtils.isEmpty(list1));
System.out.println(CollectionUtils.isNotEmpty(list1));
7.是否包含任一
List<Integer> list1 = Arrays.asList(1,2,3);
List<Integer> list2 = Arrays.asList(3,2,1);
List<Integer> list3 = Arrays.asList(3);
List<List<Integer>> all = Lists.newArrayList(list1,list2,list3);
System.out.println(CollectionUtils.containsAny(all,list1,list2));
System.out.println(CollectionUtils.containsAny(list1,4,5));
System.out.println(CollectionUtils.containsAny(list1,2,4));
System.out.println(CollectionUtils.containsAny(list2,list1));
8.是否包含全部
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.containsAll(list1, list2));
List<Integer> list3=Arrays.asList(1,2,3);
List<Integer> list4=Arrays.asList(3,2,1);
System.out.println(CollectionUtils.containsAll(list3, list4));
9.是否为子集
List<Integer> list1=Arrays.asList(1,2,3);
List<Integer> list2=Arrays.asList(3,4,5);
System.out.println(CollectionUtils.isSubCollection(list1, list2));
List<Integer> list3=Arrays.asList(1,2,3);
List<Integer> list4=Arrays.asList(3,2,1);
System.out.println(CollectionUtils.isSubCollection(list3, list4));
System.out.println(CollectionUtils.containsAll(list3, list4));