public void main() {
Integer
[] a
= new Integer[] { 6, 3, 9, 3, 2, 4, 5, 7 };
Integer
[] b
= new Integer[] { 5, 8, 6, 2, 1, 9 };
List _a
= Arrays
.asList(a
);
List _b
= Arrays
.asList(b
);
Collection realA
= new ArrayList<Integer>(_a
);
Collection realB
= new ArrayList<Integer>(_b
);
realA
.retainAll(realB
);
System
.out
.println("交集结果:" + realA
);
Set result
= new HashSet();
result
.addAll(_a
);
result
.addAll(_b
);
System
.out
.println("全集结果:" + result
);
Collection aa
= new ArrayList(realA
);
Collection bb
= new ArrayList(result
);
bb
.removeAll(aa
);
System
.out
.println("最终结果:" + bb
);
}
交集结果:[6, 9, 2, 5]全集:[1, 2, 3, 4, 5, 6, 7, 8, 9]最终结果:[1, 3, 4, 7, 8]**