The method is given a list of strings called list
and a string value
. Implement it so that it returns the index of the last occurrence of...
X1021: Find Last Index
The method is given a list of strings called list
and a
string value
.
Implement it so that it returns the index of the last
occurrence of value
in list
.
For example, given ["cat", "dog", "goose", "dog", "cat"] and "dog", this method would return 3 (the index where the second occurrence of "dog" appears).
If list
does not contain the value
, this method should
return -1
.
For example, given ["cat", "dog", "goose", "dog", "cat"]
and "salamander", this method would return -1.
Hint: Remember that when comparing Strings you must
use string1.equals(string2)
, not string1 == string2
.
Your Answer:
Feedback
Your feedback will appear here when you check your answer.