Here you can find the source of intersection(List
public static <T> List<T> intersection(List<T> set1, List<T> set2)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> intersection(List<T> set1, List<T> set2) { List<T> intSet = new ArrayList<T>(set1); intSet.retainAll(set2);// w w w . j a v a 2 s. c o m return intSet; } }