Answers for "java how to return the index of an array"

4

java indexof array

java.util.Arrays.asList(theArray).indexOf(o)
Posted by: Guest on March-18-2020
1

how to print the index of an array in java

public class PrintArray {  
    public static void main(String[] args) {  
        //Initialize array  
        int [] arr = new int [] {1, 2, 3, 4, 5};  
        System.out.println("Elements of given array: ");  
        //Loop through the array by incrementing value of i  
        for (int i = 0; i < arr.length; i++) {  
            System.out.print(arr[i] + " ");  
        }  
    }  
}
Posted by: Guest on November-11-2021

Code answers related to "java how to return the index of an array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language