+ 1
Can anyone explain why the outcome of this for lope is "5"?
int outcome = 5; for (int i = -3; i < 4; i += 2){ outcome = outcome - i; } System.out.println(outcome);
1 Resposta
+ 4
outcome =5
I = - 3
outcome =outcome - i ; => 5 - -3 = 8
i = i +2 = - 3 +2 =-1
Outcome = 8 - -1 = 8+1=9
i = - 1 +2 = 1
Outcome = 9 - 1 =8
i = 1 +2 =3
Outcome = 8 - 3 = 5
I = 3 +2 =5 and i<4 condition fails so
outcome value is 5 finally...