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

17th Jan 2019, 12:52 PM
Gafoor Ezzati
Gafoor Ezzati - avatar
7 Answers
17th Jan 2019, 1:43 PM
Gafoor Ezzati
Gafoor Ezzati - avatar
+ 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.
17th Jan 2019, 2:52 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 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.
17th Jan 2019, 1:04 PM
Gordon
Gordon - avatar
+ 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 đŸ’Ș
17th Jan 2019, 2:39 PM
Gordon
Gordon - avatar
+ 2
Yes Because you wanted to use "gg" but you typed "gg ", same for the other array elements.
17th Jan 2019, 2:49 PM
Gordon
Gordon - avatar
+ 1
This error was due to the fact that each cell in the array was spaced apart after the string
17th Jan 2019, 2:43 PM
Gafoor Ezzati
Gafoor Ezzati - avatar
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?
17th Jan 2019, 1:25 PM
Gafoor Ezzati
Gafoor Ezzati - avatar