Here you can find the source of containsAny(Collection
public static <V> boolean containsAny(Collection<V> firstCollection, Collection<V> secondCollection)
//package com.java2s; //License from project: BSD License import java.util.Collection; public class Main { public static <V> boolean containsAny(Collection<V> firstCollection, Collection<V> secondCollection) { for (V firstCollectionValue : firstCollection) { for (V secondCollectionValue : secondCollection) { if (firstCollectionValue != null && firstCollectionValue.equals(secondCollectionValue)) { return true; }//ww w . j a v a 2 s .c o m } } return false; } }