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: LGPL import java.util.Arrays; import java.util.List; public class Main { public static <E> List<E> intersection(List<E> list1, List<E> list2) { list1.retainAll(list2);//w ww . ja v a 2s .c o m return list1; } public static <E> List<E> intersection(E[] array1, E[] array2) { return intersection(Arrays.asList(array1), Arrays.asList(array2)); } }