String.lastIndexOf
Class Overview | Class Members |
This Package |
All Packages
public int lastIndexOf( String str )
Parameters
- str
- the substring to search for.
Returns
if the string argument occurs one or more times as a substring
within this object, then the index of the first character of
the last such substring is returned. If it does not occur as
a substring, -1 is returned.
Description
Returns the index within this string of the rightmost occurrence
of the specified substring. The rightmost empty string "" is
considered to occur at the index value this.length().
public int lastIndexOf( String str,
int fromIndex )
Parameters
- str
- the substring to search for.
- fromIndex
- the index to start the search from.
Returns
If the string argument occurs one or more times as a substring
within this object at a starting index no greater than
fromIndex, then the index of the first character of
the last such substring is returned. If it does not occur as a
substring starting at fromIndex or earlier,
-1 is returned.
Description
Returns the index within this string of the last occurrence of
the specified substring.
The returned index indicates the start of the substring, and it
must be equal to or less than fromIndex.