hi, Smith
this kind of problem you can take a look of API
doc.
i try to explain:
first, indexOf() is search from start and lastIndexOf() is search from end.
second, indexOf() is find the lowest value as
str.startWith("Jives", 4) && k>=4(according to doc
), so find String str is "Jives, Java Jives Java" and result is 5;
lastIndexOf() is find the largest value as
str.startWith("Jives", 5) && k<=5, so find String str is "Java J", it can find at positoin 5->J, so result is 5;
hop this can help
michael