Java Array Contain arrayContains(int[] arr, int e)

Here you can find the source of arrayContains(int[] arr, int e)

Description

checks if an int array contains an int element

License

Open Source License

Parameter

Parameter Description
arr the int array
e the element

Return

boolean true or false

Declaration

public static boolean arrayContains(int[] arr, int e) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w ww  .  java2  s  . co m*/
     * checks if an int array contains an int element
     *
     * @param arr the int array
     * @param e the element
     * @return boolean true or false
     */
    public static boolean arrayContains(int[] arr, int e) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == e)
                return true;
        }
        return false;
    }
}

Related

  1. arrayContains(final E[] arr, final E targetValue)
  2. arrayContains(final int[] array, final int v)
  3. arrayContains(final Object[] a, final Object v)
  4. arrayContains(final String[] array, String needle)
  5. arrayContains(final T[] array, final T v)
  6. arrayContains(int[] arr, int ii)
  7. arrayContains(int[] array, int value)
  8. arrayContains(int[] array, int value)
  9. arrayContains(Object obj, Object[] array)