
-----------------------------------
xtreemboarder
Thu Jan 26, 2006 8:49 pm

indexOf on array
-----------------------------------
how do you indexOf on arrays?

would it be like:

int num = array.indexOf ("hello");

???????????????????

-----------------------------------
rizzix
Thu Jan 26, 2006 9:04 pm


-----------------------------------
Short Answer: You can't.

Long Answer: You can, but it's a little different. 

First sort your array.Arrays.sort(array);
Second use binarySearch.int index = Arrays.binarySearch(array, "somevalue");

-----------------------------------
wtd
Thu Jan 26, 2006 9:09 pm


-----------------------------------
Or you could use Arrays.asList to get a List and then call that list's indexOf method.
