Scala String indexOf(int ch, int fromIndex) method with example
The indexOf(int ch, int fromIndex) method is same as indexOf() method but here this method starts finding the character from the index we specify.
Method Definition: int indexOf(int ch, int fromIndex)
Return Type: It returns the index of the character specified in the argument.
So, here the first occurrence of ‘i’ is after second index is four So, 4 is returned as output.
Here, the first occurrence of ‘h’ after 4th index is 9. So, its returned.