I cannot seem to figure out how to do this.. I'm stuck. I can solve it in my head but i can't figure out how to write the code. I know this code probably isn't even close to right, but I'm not sure if the easiest way to go about this is to convert the chars string into a character array or if I'm close here?
I know that what I wrote is wrong but I just wanted to write it out like that because it's basically what I'm trying to do. Your help is appreciated!
public static int indexOfAny(String s, String chars) {
for (int i = 0; i <= s.length(); i++) {
if ((s.charAt(i)).equals(chars)) {
return i;
} else {
return -1;
}
}
}