To find the index of an element in an array in Java, do this:
java.util.Arrays.asList(array).indexOf(element)
.Here's how you do it:
Integer[] integerArray = new Integer[] { 34, 3, 55, 11, 1 };
int indexOfFiftyFive = java.util.Arrays.asList(integerArray).indexOf(55);
System.out.println(indexOfFiftyFive); // 2
String[] stringArray = new String[] { "Hello", "World", "!" };
int indexOfWorld = java.util.Arrays.asList(stringArray).indexOf("World");
System.out.println(indexOfWorld); // 1