Computer Applications
Describe the purpose and write the syntax of indexOf() function.
Java String Handling
ICSE 2010
18 Likes
Answer
It returns the index of the first occurrence of the specified character within the string or -1 if the character is not present.
Syntax:
int <variable-name> = <string-variable>.indexOf(<character>);
Answered By
10 Likes