Here you can find the source of intersection(List
public static <T> List<T> intersection(List<T> arrayOne, List<T> arrayTwo)
//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> intersection(List<T> arrayOne, List<T> arrayTwo) { List<T> _intersect = new ArrayList<T>(); for (int i = 0; i < arrayOne.size(); i++) { for (int j = 0; j < arrayTwo.size(); j++) { if (arrayOne.get(i) == arrayTwo.get(j)) { _intersect.add(arrayOne.get(i)); }/* www. j a va 2 s. c om*/ } } return _intersect; } }