Here you can find the source of arrayContains(T[] array, T value)
Parameter | Description |
---|---|
T | Type of array elements and <code>value</code> |
array | Array to examine |
value | Value to search |
true
if array
contains value
, false
otherwise
public static <T> boolean arrayContains(T[] array, T value)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . ja v a 2 s.c o m*/ * Checks if the given array contains the specified value.<br> * * @param <T> * Type of array elements and <code>value</code> * @param array * Array to examine * @param value * Value to search * @return <code>true</code> if <code>array</code> contains * <code>value</code>, <code>false</code> otherwise */ public static <T> boolean arrayContains(T[] array, T value) { for (int i = 0; i < array.length; i++) { if (array[i] == value) { return true; } } return false; } }