chuck finley chuck finley - 7 months ago 28
Java Question

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 ?

Answer

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");