What is indexof() method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is indexof() method

what is indexof() method describe

5th Mar 2017, 4:10 AM
Abhi
Abhi - avatar
3 Answers
+ 6
indexOf method is mainly an array method ( wich return the first index item corresponding )... As strings can be considered as arrays of characters, the indexOf method can also be applied on it as explained by @Nikhil Kumar ;)
5th Mar 2017, 10:42 PM
visph
visph - avatar
+ 4
indexOf() method is used to return the first occurrence of the character that is passed in as an argument. Eg: String str = "Nikhil"; int i = str.indexOf ('i'); SOPln (i); output will be 1. note: counting is zero indexed based.
5th Mar 2017, 4:51 AM
Nikhil Kumar
Nikhil Kumar - avatar
0
hello nikhil I don't understand indexof() method please explain more example
7th Mar 2017, 2:38 AM
Abhi
Abhi - avatar