Java Array Contain arrayContainsElement(T[] array, T element)

Here you can find the source of arrayContainsElement(T[] array, T element)

Description

array Contains Element

License

Open Source License

Parameter

Parameter Description
array a parameter
element a parameter

Declaration

public static <T> boolean arrayContainsElement(T[] array, T element) 

Method Source Code

//package com.java2s;
/*/*from www. j av a  2s .  co  m*/
 * Copyright ? 2014 Universidad Icesi
 * 
 * This file is part of the SLR Tools.
 * 
 * The SLR Tools are free software: you can redistribute it 
 * and/or modify it under the terms of the GNU Lesser General 
 * Public License as published by the Free Software 
 * Foundation, either version 3 of the License, or (at your 
 * option) any later version.
 * 
 * The SLR Tools are distributed in the hope that it will be 
 * useful, but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 * PURPOSE. See the GNU Lesser General Public License for 
 * more details.
 * 
 * You should have received a copy of the GNU Lesser General 
 * Public License along with The SLR Support Tools. If not, 
 * see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * 
     * @param array
     * @param element
     * @return
     */
    public static <T> boolean arrayContainsElement(T[] array, T element) {
        boolean containsElement = false;
        for (int i = 0; (i < array.length) && !containsElement; i++) {
            T arrayElement = array[i];
            if (arrayElement != null && arrayElement.equals(element)) {
                containsElement = true;
            }
        }
        return containsElement;
    }
}

Related

  1. arrayContains(T[] array, T value)
  2. arrayContains(T[] source, T[] target)
  3. arrayContains(T[] src, T target)
  4. arrayContains(T[] ts, T t)
  5. arrayContains1(String[] parent, String[] child)
  6. arrayContainsEntry(T[] array, T entry)
  7. arrayContainsIgnoreCase(String[] array, String searchKey)
  8. arrayContainsIgnoreCase(String[] array, String str)
  9. arrayContainsInt(int[] array, int test)