0
(please help me)why don't print distanceSum in my code
i have a code but distanceSum variable size doesnt change. in other words, the sum is not done. https://code.sololearn.com/cshPePbDmxIN/?ref=app
7 Answers
+ 2
i solve this
https://code.sololearn.com/cm1uXpjnS0H4/?ref=app
+ 8
Gafoor Ezzati
Yes, I think u have corrected code in String array , element is "gg " (not "gg") by idea of debugging by Gordon đ
â some tip : try to use .equals() method in place of == operator for content comparision of String values.
+ 3
It is a small typo.
There is an ancient Chinese idiom:
"Teaching fishing is better than giving a fish".
Instead of telling you directly,
Let me teach you debugging,
You print middle result like this:
https://code.sololearn.com/ciZav0iV5n6c/?ref=app
Please share your findings with me.
+ 3
Yes it's just a simple typo, isn't itđ
And my testing process is like this
1. Add the line 10 (it appears shifted 2 lines, because the auto credit)
2. Add line 25 (didn't show, means "gg" is not met)
3. Add line 21 (show gg)
Here I know the answer already, but to make it clear:
4. Add end to line 21, confirmed the reason.
(make the extra space obvious)
Hope above inspires your ability to debug codes, keep up đȘ
+ 2
Yes
Because you wanted to use "gg" but you typed "gg ", same for the other array elements.
+ 1
This error was due to the fact that each cell in the array was spaced apart after the string
0
initial value of dostance som is zero
but in line 22 since the last string is "gg", the distanceSum valu must be sum with 50 (aagg) but it does not sum.why?