Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Main { public static <T> Set<T> intersect(Collection<T> l1, Collection<T> l2) { Set<T> nl = new HashSet<T>(l1); nl.retainAll(l2); return nl; } }