Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.Set; public class Main { public static Set intersection(Set one, Set two) { Set big, small; if (one.size() >= two.size()) { big = new HashSet(one); small = two; } else { big = new HashSet(two); small = one; } big.removeAll(small); return big; } }