+ 1
What happened here...say int b=3; int a=16; b+=++a; system.out.println(b);
how did the answer came to be....
3 Réponses
+ 8
b += ++a;
b += 4; // pre-increment
b = b + 4;
b = 20
+ 3
@Mihail
The original value is not returned because this is the pre-increment (also called pre-fix)
++x first increments x then uses x.
So, b becomes 4, then 4 is returned.
16 + 4 = 20.
+ 1
it should be 19
because ++a adds one but returns it's original value and 16+3=19