Java Array Contain arrayContains(T[] array, T value)

Here you can find the source of arrayContains(T[] array, T value)

Description

Checks if the given array contains the specified value.

License

Open Source License

Parameter

Parameter Description
T Type of array elements and <code>value</code>
array Array to examine
value Value to search

Return

true if array contains value, false otherwise

Declaration

public static <T> boolean arrayContains(T[] array, T value) 

Method Source Code

//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;
    }
}

Related

  1. arrayContains(String[] pArray, String pItem)
  2. ArrayContains(String[][] arr, String s)
  3. arrayContains(T haystack[], T needle)
  4. arrayContains(T search, T[] array, boolean def)
  5. arrayContains(T[] arr, T item)
  6. arrayContains(T[] source, T[] target)
  7. arrayContains(T[] src, T target)
  8. arrayContains(T[] ts, T t)
  9. arrayContains1(String[] parent, String[] child)