How do I find items in an array?
Category: commons.lang, viewed: 23179 time(s).
This example demonstrate how to find items in array. We use the ArrayUtils class. This class provides method such as contains(Object[] array, Object objectToFind) to check if the array contains some value. We can also use the indexOf(Object[] array, Object objectToFind) and lastIndexOf(Object[] array, Object objectToFind) methods to gen the index of array where our object is located.
Here are the result of the code above.
Contains Blue? true indexOfYellow = 2 indexOfOrange = 1 lastIndexOfOrange = 6
Can't find what you are looking for? Join our FORUMS and ask some questions!
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!
