go to previous page   go to home page   go to next page

Answer:

6

The first occurrence of the string "a" within the method's string is at index 6.


Play with indexOf()

Play with the following to gain insight into indexOf().

Try searching for the second occurrence of "ant" in the line. Pay attention to spaces.


String line = ; // Enter a string here between quotes

String target = ; // Enter a string here between quotes

int location = line.indexOf( target );

location:


QUESTION 10:

What is the index of the empty string "" ?


go to previous page   go to home page   go to next page