Jamie Jamie - 4 months ago 36
Java Question

Where is Java's Array indexOf?

I must be missing something very obvious, but I've searched all over and can't find this method.


There are a couple of ways to accomplish this using the Arrays utility class.

If the array is not sorted:


If the array is sorted, you can make use of a binary search for performance:

java.util.Arrays.binarySearch(theArray, o)