Here you can find the source of containsAny(final Collection> collection1, final Collection> collection2)
static boolean containsAny(final Collection<?> collection1, final Collection<?> collection2)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { static boolean containsAny(final Collection<?> collection1, final Collection<?> collection2) { for (final Object value : collection1) { if (collection2.contains(value)) { return true; }//from w ww . j a v a 2 s . c o m } return false; } }