Here you can find the source of equalsAny(T element, T[] array)
Parameter | Description |
---|---|
element | the element to look for |
array | the array to look over |
T | COMMENT |
public static <T> boolean equalsAny(T element, T[] array)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/* ww w . j a va 2s . co m*/ * equalsAny compares a given element with all elements of a given array. * If an array element is equal to the given element {@code true} is * returned, otherwise the return value is {@code false}. * * @param element the element to look for * @param array the array to look over * * @return {@code true} if there is an element in the array, that is * equal to the given element, {@code false} otherwise * * @param <T> COMMENT */ public static <T> boolean equalsAny(T element, T[] array) { for (T e : array) if (e.equals(element)) return true; return false; } /** * equalsAny compares a given element with all elements of a given list. * If a list element is equal to the given element {@code true} is * returned, otherwise the return value is {@code false}. * * @param element the element to look for * @param list the list to look over * * @return {@code true} if there is an element in the list, that is * equal to the given element, {@code false} otherwise * * @param <T> COMMENT */ public static <T> boolean equalsAny(T element, List<T> list) { for (T e : list) if (e.equals(element)) return true; return false; } }