0

Need help can someone please explain this?

https://code.sololearn.com/crHkZV3l747v/?ref=app

22nd Oct 2022, 12:23 PM
Mozzie
Mozzie - avatar
5 Answers
+ 2
Kim Jonas Cabugayan String book = new String("123456789"); book.indexOf('4',4); it finds '4' from index 4. If it found then Index value is returned else returns -1. String book have '4' at index 3. but From index 4, there is no '4' exist after that so returning -1. edit:
22nd Oct 2022, 12:28 PM
Jayakrishna 🇼🇳
+ 2
Kim Jonas Cabugayan indexOf('4', 4) means index of 4 will be search from position 4 but '4' is located at index '3' so -1 If you give ('4', 1) then searching will be start from index 1 so index of '4' will be 3
22nd Oct 2022, 12:42 PM
AÍąJ
AÍąJ - avatar
22nd Oct 2022, 12:47 PM
Mozzie
Mozzie - avatar
+ 1
Jayakrishna🇼🇳 Can you explain in layman terms?
22nd Oct 2022, 12:30 PM
Mozzie
Mozzie - avatar
+ 1
I updated some more clear terms.. May it helps.. Kim Jonas Cabugayan
22nd Oct 2022, 12:44 PM
Jayakrishna 🇼🇳