Here you can find the source of intersection(List
public static <E> List<E> intersection(List<E> list1, List<E> list2)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <E> List<E> intersection(List<E> list1, List<E> list2) { if (list1 == null || list2 == null) throw new NullPointerException("Not initizalized lists"); List<E> intersection = new LinkedList<E>(); E item;//from w w w.j a va2 s .c o m ListIterator<E> iter = list1.listIterator(); while (iter.hasNext()) { item = iter.next(); if (list2.contains(item)) { intersection.add(item); } } return intersection; } }