What is the mistake I have done here ,can someone explain please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the mistake I have done here ,can someone explain please?

Problem in a code ,help. https://code.sololearn.com/c068N3b4t0OR/?ref=app

2nd Apr 2020, 7:59 AM
Rajan krishnan
Rajan krishnan - avatar
2 Answers
+ 2
Assume the input is "Carrie". Carrie 012345 - The last index is 5. But the length of the string is 6. In the first loop it won't found index 6 and cause error. You can do for(i = l-1 ; i>=0 ; i--) to avoid it.
2nd Apr 2020, 8:07 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Thanks ,got it👍 I m a newbie in java now.
2nd Apr 2020, 8:13 AM
Rajan krishnan
Rajan krishnan - avatar