Here you can find the source of intersection(List
public static <T> List<T> intersection(List<T> list1, List<T> list2)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> intersection(List<T> list1, List<T> list2) { List<T> ret = new ArrayList<T>(); for (T i : list1) { if (list2.contains(i)) ret.add(i);//from w w w . ja va 2 s. c o m } return ret; } }