Home » java » Java String Method indexOf with int parameter

Java String Method indexOf with int parameter

indexOf(int ch) method is used to get the first occurrence of a character in given string. This method takes a character input (in Unicode code units) and return the index value of character in string, if character not found in string then it returns -1.

Signature

public int indexOf(int ch)

Parameters

A charcter value in unicode code point.

Return

Returns the int value that represents the first occurance of the character in string, if character not fount in string then it returns -1.

Example

Managed by MochaHost - Fast & Easy WordPress Hosting