Here you can find the source of hasIntersection(Collection
public static <T> boolean hasIntersection(Collection<T> c1, Collection<T> c2)
//package com.java2s; import java.util.Collection; public class Main { public static <T> boolean hasIntersection(Collection<T> c1, Collection<T> c2) { boolean flag = false; for (T t : c2) { if (c1.contains(t)) { flag = true;/*from w w w.j av a2s .c o m*/ break; } } return flag; } public static <T> boolean contains(Collection<T> c1, Collection<T> c2) { boolean flag = true; for (T t : c2) { if (!c1.contains(t)) { flag = false; break; } } return flag; } }