0
Need help can someone please explain this?
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:
+ 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
+ 2
Thanks Jayakrishna🇮🇳 A͢J
+ 1
Jayakrishna🇮🇳
Can you explain in layman terms?
+ 1
I updated some more clear terms.. May it helps.. Kim Jonas Cabugayan