CollectionUtils的几个方法

  //并集 
  Collection<String> union = CollectionUtils.union(a, b); 
  //交集 
  Collection<String> intersection = CollectionUtils.intersection(a, b); 
  //交集的补集 
  Collection<String> disjunction = CollectionUtils.disjunction(a, b); 
  //集合相减
Collection<String> subtract = CollectionUtils.subtract(a, b); 

A: {1,2,3,3,4,5}
B: {3,4,4,5,6,7}
--------------------------------------------
Union(A, B): {1,2,3,3,4,4,5,6,7}
Intersection(A, B): {3,4,5}
Disjunction(A, B): {1,2,3,4,6,7}
Subtract(A, B): {1,2,3}

你可能感兴趣的:(Collection)