The reason is -> ans is a reference to an immutable object so when you change the value(from 1234 to 8888), you actually create a new immutable object with a value of 8888 that’s referenced by data. So the original reference ans is still referring to the immutable object 1234 and data will refer to the immutable object 8888.