find Array Index for string array - Android java.lang

Android examples for java.lang:array

Description

find Array Index for string array

Demo Code


public class Main{


    public static int findArrayIndex(String[] arr, String str) {
        int iReturn = -1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].equals(str)) {
                iReturn = i;//from  w  ww.j a  va2s.c  o  m
                break;
            }
        }
        return iReturn;
    }

}

Related Tutorials