Integer objects are immutable. When you write a = 6, that isn't changing the state of the Integer object, it's assigning a different Integer object to a. So b is unchanged.
This is one of the advantages of working with immutable classes (
String is a common example) - once you have a reference to one you don't have to worry about other code changing its value, so the code is easier to understand.