The output of current program is \"Strange\". But both the variables share the same reference. Why are the second and third comparisons not true?
Integer a;
That's the artifact of autoboxing and a fact that Integer is immutable in Java.
The a++ and a-- are translated to roughly this.
a++
a--
int intA = a.getInt( ); intA++; a = Integer.valueOf( intA ); // this is a reference different from b