Share via


String.indexOf

Class Overview | Class Members | This Package | All Packages

Syntax 1

public int indexOf( int ch )

Parameters
  • ch
    a character.
Returns

the index of the first 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 first occurrence of the specified character.

Syntax 2

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

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

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

Description

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.