The ________ method of the String class returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

  • indexOf(char ch)
  • indexOf(char ch, int fromIndex)
  • lastIndexOf(char ch)
  • lastIndexOf(char ch, int fromIndex)
The lastIndexOf(char ch, int fromIndex) method of the String class is used to find the index of the last occurrence of the specified character within the string, starting the search from the given index fromIndex. The other options are related to the indexOf method but don't perform the same task.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *