The following code prints out \"3\", not \"4\" as you might expect.
public class Foo2 {
public static void main(String[] args) {
int a=1, b=2;
Postfix ++ increments the value of variable, and returns the value that was there before the increment. Thus, the return value of operator++ in your example will be 1, and of course 1 + 2 will give 3, which is then assigned to a. By the time of assignment, ++ has already incremented the value of a to 2 (because of precedence), so = overwrites that incremented value.