Java examples for java.util:Collection Contain
check if one collection contains Any elements from another collection
//package com.java2s; import java.util.Collection; public class Main { public static void main(String[] argv) { Collection collection1 = java.util.Arrays.asList("asdf", "java2s.com"); Collection collection2 = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(containsAny(collection1, collection2)); }//from ww w . ja v a2s .c om static boolean containsAny(final Collection<?> collection1, final Collection<?> collection2) { for (final Object value : collection1) { if (collection2.contains(value)) { return true; } } return false; } }