Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> Collection<T> intersect(Collection<T> col1, Collection<T> col2) { Collection<T> col1Clone = clone(col1); col1Clone.retainAll(col2); return col1Clone; } public static <T> List<T> clone(Collection<T> col) { List<T> destCol = new ArrayList<T>(); for (T o : col) { destCol.add(o); } return destCol; } }