0

How its result 17? can anyone explain

What is the output of this code? int result = 0; for (int i = 0; i < 5; i++) { if (i == 3) { result += 10; } else { result += i; } } System.out.println(result); //Output : 17 actually i don't understand " result+=" this section;

25th Dec 2016, 6:56 AM
Kabir Mandal
Kabir Mandal - avatar
1 Odpowiedź
+ 2
+= its an operator that add the current value + the new one. result = result + i; or result+=i; both codes do the same.
25th Dec 2016, 7:02 AM
Nahuel
Nahuel - avatar