Here you can find the source of intersection(Collection
public static <T> List<T> intersection(Collection<T> a, Collection<T> b)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> List<T> intersection(Collection<T> a, Collection<T> b) { List<T> list = new ArrayList<T>(); for (T element : a) { if (b.contains(element)) { list.add(element);/*from www . ja va 2 s . co m*/ } } return list; } }