Jamie Jamie - 1 year ago 107
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.

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download