Java Array Has arrayHas(int[] arr, int val)

Here you can find the source of arrayHas(int[] arr, int val)

Description

Helper method to check if an int array contains an int.

License

Open Source License

Declaration

public static boolean arrayHas(int[] arr, int val) 

Method Source Code

//package com.java2s;
/**/*from ww w.j a va 2 s. com*/
 * This class was created by <Vazkii>. It's distributed as
 * part of the Botania Mod. Get the Source Code in github:
 * https://github.com/Vazkii/Botania
 * 
 * Botania is Open Source and distributed under the
 * Botania License: http://botaniamod.net/license.php
 * 
 * File Created @ [Feb 14, 2015, 3:28:54 PM (GMT)]
 */

public class Main {
    /**
     * Helper method to check if an int array contains an int.
     */
    public static boolean arrayHas(int[] arr, int val) {
        for (int element : arr)
            if (element == val)
                return true;

        return false;
    }
}

Related

  1. arrayHasContent(Object[] array)
  2. arrayHasContiguousRowEntries(double[] aVector)
  3. arrayHasElements(Object[] obj)
  4. arrayHasTaints(int[] a)