0

Why this example prints 17?

Good evening coders. I started to learn java and I finaly done with arrays, but i dont understand why following example returns 17. https://code.sololearn.com/cwITzSH1f4hG/?ref=app

6th May 2017, 8:53 PM
Andrew Lashevich
Andrew Lashevich - avatar
3 ответов
+ 6
In the loop there an addition inside conditional operator 0+1+2+10+4 = 17
6th May 2017, 9:06 PM
Alexey
Alexey - avatar
+ 5
It is compound assignment operation a +=1 is the same as a = a + 1 You could use += -= *= /= %=
6th May 2017, 9:23 PM
Alexey
Alexey - avatar
0
Thanks, but what does a "+=" symbol? I didn't get it at all.
6th May 2017, 9:08 PM
Andrew Lashevich
Andrew Lashevich - avatar