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!

posted @ 2014-07-19 21:19  伟大的臭猪猪  阅读(4214)  评论(1编辑  收藏  举报