Here you can find the source of isAnyIncludedIn(Collection
Parameter | Description |
---|---|
findAnyOfThese | which elements to look for. |
inThisCollection | where to look for them. |
E | type of the elements in question. |
public static <E> boolean isAnyIncludedIn(Collection<E> findAnyOfThese, Collection<E> inThisCollection)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Collection; public class Main { /**/*w w w .j ava 2s .c o m*/ * Checks if any of the elements in the first collection can be found in the * second collection. * * @param findAnyOfThese which elements to look for. * @param inThisCollection where to look for them. * @param <E> type of the elements in question. * @return {@code true} if any of the elements in {@code findAnyOfThese} can * be found in {@code inThisCollection}, {@code false} otherwise. */ public static <E> boolean isAnyIncludedIn(Collection<E> findAnyOfThese, Collection<E> inThisCollection) { for (E findThisItem : findAnyOfThese) { if (inThisCollection.contains(findThisItem)) { return true; } } return false; } }