Java tutorial
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static boolean containsAny(Collection source, Collection candidates) { if (!isEmpty(source) && !isEmpty(candidates)) { Iterator it = candidates.iterator(); do { if (!it.hasNext()) { return false; } } while (!source.contains(it.next())); return true; } else { return false; } } public static boolean isEmpty(Collection collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Map map) { return map == null || map.isEmpty(); } }