Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.Collection;

public class Main {
    /**
     * 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;
    }
}