java求两个集合的差集

public static void main(String[] args) {
Set set = new HashSet();
Set set1 = new HashSet();
set.add("sanny");
set.add("mary");
set.add("bill");
set.add("tom");
set.add("tony");
set.add("mark");
set.add("smith");
set.add("anny");

set1.add("smith");
set1.add("tom");
set1.add("tony");
set1.add("mark");

set.removeAll(set1);// sooooooo easy!

原文地址:https://www.cnblogs.com/lucky-star-star/p/3855502.html