posted 16 years ago
Hi,
I know this is a bad question. In real situation we won't use this. But I just want to know why this happens.
int a = 1;
a = a++;
System.out.println(a);
Why does this print 1?
Since this is a postfix increment, the value is assigned first So value is 1. Then executes the postfix increment. So value should be 2.
Anybody knows the answer?