Computer Applications
Mention the purpose and syntax of indexOf() method.
Java String Handling
2 Likes
Answer
The indexOf() method returns the index of the first occurrence of the specified character (passed as an argument) in a string. If the character is present in the string, the method will return the index number; otherwise, it will return -1.
Syntax:stringObject.indexOf(char)
Answered By
2 Likes