Here you can find the source of intersect(Collection
public static <T> boolean intersect(Collection<T> t1, Collection<T> t2)
//package com.java2s; import java.util.Collection; public class Main { public static <T> boolean intersect(Collection<T> t1, Collection<T> t2) { for (T t : t1) { if (t2.contains(t)) { return true; }/* w ww . j a v a2 s .c om*/ } return false; } }