Java Array Has inArray(final T[] array, final U search)

Here you can find the source of inArray(final T[] array, final U search)

Description

Check whether the given array contains the given search object.

License

Apache License

Parameter

Parameter Description
array The array to search through.
search The object to search for in the array.

Return

true if the search object was found in the array.

Declaration

public static <T, U extends T> boolean inArray(final T[] array, final U search) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w  w w .j a  v a  2 s. c o  m*/
     * Check whether the given array contains the given search object.
     *
     * @param array  The array to search through.
     * @param search The object to search for in the array.
     *
     * @return {@code true} if the search object was found in the array.
     */
    public static <T, U extends T> boolean inArray(final T[] array, final U search) {

        for (final T element : array)
            if (search.equals(element))
                return true;

        return false;
    }
}

Related

  1. arrayHasTaints(int[] a)
  2. inArray(byte needle, byte[] haystack)
  3. inArray(byte needle, byte[] haystack)
  4. inArray(char[] array, char c)
  5. inArray(final String s, final String[] array)
  6. inArray(int[] arr, int search)
  7. inArray(int[] array, int needle)
  8. inArray(Object[] ps, Object p)
  9. inArray(String arg, String[] array)