This example will find the index of a given primitive or object value within an array while using java, guava and apache commons.
Straight up Java
While using the core jdk we will create an array of Strings and Integers then call Arrays.asList to convert to an arraylist. Next we will call ArrayList.indexOf which will return the index of the first occurrence of the specified element in this list.
Using guava's Iterators class we will pass a predicate to Iterators.indexOf which will return the index of the first element that satisfies the provided predicate or in this case that matches "Lily Elite".
To find the index of primitive array using guava, we will use Ints class that contains static utility methods pertaining to int primitives. The Ints.indexOf will return the index of the first apperance of the value specified or in this case 3.
Apache commons ArrayUtils class contains operations on primitive or object arrays. We will ArrayUtils.indexOf which will find the index of the given value in the array.