Here you can find the source of intersect(Set> a, List> b)
public static boolean intersect(Set<?> a, List<?> b)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; import java.util.Set; public class Main { public static boolean intersect(Set<?> a, List<?> b) { return intersect(a, (Iterable<?>) b); }//w w w . j a v a2 s.com public static boolean intersect(Collection<?> a, Collection<?> b) { if (b.size() > a.size()) { Collection<?> c = a; a = b; b = c; } return intersect(a, (Iterable<?>) b); } public static boolean intersect(Collection<?> a, Iterable<?> iterable) { for (Object ele : iterable) { if (a.contains(ele)) return true; } return false; } }