Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Set; public class Main { public static <T> boolean overlaps(Set<T> a, Set<T> b) { if (a.size() > b.size()) { Set<T> t = a; a = b; b = t; } for (T elem : a) { if (b.contains(elem)) { return true; } } return false; } }