String.lastIndexOf

Class Overview | Class Members | This Package | All Packages

Syntax 1

public int lastIndexOf( int ch )

Parameters
  • ch
    a character.
Returns

the index of the last occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

Description

Returns the index within this string of the last occurrence of the specified character. The String is searched backwards starting at the last character.

Syntax 2

public int lastIndexOf( int ch**, int** fromIndex )

Parameters
  • ch
    a character.
  • fromIndex
    the index to start the search from.
Returns

the index of the last occurrence of the character in the character sequence represented by this object that is less than or equal to fromIndex, or -1 if the character does not occur before that point.

Description

Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.