Java Collection Contain containsAny(Collection collection, Collection toCheck)

Here you can find the source of containsAny(Collection collection, Collection toCheck)

Description

if any item in toCheck is present in collection

License

Open Source License

Parameter

Parameter Description
collection a parameter
toCheck a parameter

Declaration

public static <T> boolean containsAny(Collection<T> collection, Collection<T> toCheck) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**//w ww . j a  v  a  2  s. co m
     * if any item in toCheck is present in collection
     *
     * @param collection
     * @param toCheck
     */
    public static <T> boolean containsAny(Collection<T> collection, Collection<T> toCheck) {
        for (T c : toCheck) {
            if (collection.contains(c))
                return true;
        }
        return false;

    }
}

Related

  1. containsAny(Collection c1, Collection c2)
  2. containsAny(Collection set, Iterable elements)
  3. containsAny(Collection c, String... toCheck)
  4. containsAny(Collection strs, Collection searchTerms)
  5. containsAny(Collection collection, Collection query)
  6. containsAny(Collection list, Collection values)
  7. containsAny(Collection src, Collection containsAny)
  8. containsAny(Collection firstCollection, Collection secondCollection)
  9. containsAny(final Collection a, final Collection b)