check if array Contains a specific Value - Android java.lang

Android examples for java.lang:array contain

Description

check if array Contains a specific Value

Demo Code


//package com.java2s;

public class Main {
    public static boolean arrayContainsValue(Object[] array, Object value) {
        return findValueInArray(array, value) != -1;
    }//w  ww.  j  a  v  a 2s . co  m

    public static int findValueInArray(Object[] array, Object value) {
        for (int i = 0; i < array.length; i++) {
            if (array[i].equals(value))
                return i;
        }
        return -1;
    }
}

Related Tutorials