indexOf in a string array
Is there anyway to get indexOf like you would get in a string. output.add("1 2 3 4 5 6 7 8 9 10); String bigger[] = output.get(i).split(" "); int biggerWher = bigger.indexOf("10"); I wrote this code but its returning an error and not compiling! Any advice ? Use this ... output.add("1 2 3 4 5 6 7 8 9 10"); String bigger[] = output.get(i).split(" "); int biggerWher = Arrays.asList(bigger).indexOf("3"); When the array is an array of objects, then: Object[] array = .. Arrays.asList(array).indexOf(someObj); Another alternative is org.apache.commons.lang.ArrayUtils.indexOf(...) which also has