0
[Answered]While loop -- very strange flow
2 Réponses
+ 1
int a=3, b=4;
while (++a==b--){}
System.out.println(a+" "+b);
first iteration:
++a==b-- ==> 4==4 (True) ==> a=4,b=3
Second itration:
++a==b-- ==> 5==3 (False) ==> a=5,b=2
output : "5 2"
remember ++a==5 is to increment a first then check, a++==5 is to check a first then increment a.
0
So basically its
1) satisfying the condition and doing the math hence going on loop
2) not satisfying the condition and doing the math, exiting the loop