Here you can find the source of difference(Set a, Set b)
public static Set difference(Set a, Set b)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static Set difference(Set a, Set b) { Set temp = new HashSet(); temp.addAll(a);/*w w w . j a v a2 s.c o m*/ temp.removeAll(b); return temp; } }