Here you can find the source of intersect(List
public static <T> List<T> intersect(List<T> first, List<T> second)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> intersect(List<T> first, List<T> second) { ArrayList<T> result = new ArrayList<T>(); for (T obj : first) { if (second.contains(obj)) { result.add(obj);//from ww w . j av a 2 s . c o m } } return result; } }