Integers between -128 and 127 are cached (Integers of the same value reference the same Object
). Comparing your a
and b
references returns true
, because they are the same Object
. Your c
and d
are not in that range, so their reference comparison returns false
.