Here you can find the source of arrayContainsElement(T[] array, T element)
Parameter | Description |
---|---|
array | a parameter |
element | a parameter |
public static <T> boolean arrayContainsElement(T[] array, T element)
//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; } }