It is a very basic question, but I don't seem to understand why this doesn't work. As far as I know, a and b would be pointers (in C thinking) to Integer objects. Why is the output 3 2 and not 3 3? I would have expected the value of b to also be incremented when incrementing a.
Integer a = new Integer(1);
Integer b = new Integer(2);
a = b;
a++;
System.out.print(a + " " + b);