// 准备数据
String[] attr1 = new String[]{"A", "B", "C", "D", "E", "F", null};
String[] attr2 = new String[]{"1", "2", "3", "D", "E", "F", null};
ArrayList<String> list1 = new ArrayList<>(Arrays.asList(attr1));
ArrayList<String> list2 = new ArrayList<>(Arrays.asList(attr2));
// 原来的集合 list1 list2 都不会改变
System.out.println("交集:" + CollectionUtil.intersection(list1, list2)); // 交集
System.out.println("补集:" + CollectionUtil.disjunction(list1, list2)); // 补集
System.out.println("并集:" + CollectionUtil.union(list1, list2)); //并集
// list1 减去 list2
System.out.println("list1的差集" + CollectionUtil.subtract(list1, list2));
System.out.println("list2的差集" + CollectionUtil.subtract(list2, list1));
// list1 减去 list2 并转化为list
System.out.println("list1的差集:" + CollectionUtil.subtractToList(list1, list2));
System.out.println("list2的差集:" + CollectionUtil.subtractToList(list2, list1));