Look for the final instance of “planet” within a string.
String |
The lastIndexOf() method retrieves the position of the last occurrence of specified character(s) in a string.
Hint: Utilize the indexOf method to obtain the position of the first occurrence of specified character(s) in a string.
One of the following:
public |
public |
public |
public |
Parameter |
Description |
str |
A string value indicating the string to search within. |
fromIndex |
An integer value indicating the starting index position for the search. If not specified, the default value is the length of the string. |
char |
An integer value representing a single character, for example, ‘A’, or a Unicode value. |
Returns |
An integer value indicating the index of the character’s first occurrence in the string, or -1 if it does not occur. |
Locate the final instance of “e” in a string, commencing the search from position 5.
public |