Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

search an element in an array

  public static void main(String[] args) {

        int[] xr = {1, 2, 3, 4, 5};
        int key = 3;
        for (int i = 0; i < xr.length ; i++) {
            if (key==xr[i]){
                System.out.println("element is: "+i);
            }
        }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #search #element #array
ADD COMMENT
Topic
Name
8+4 =