The values of boxed primitives cannot be directly compared using the ==
and !=
operators because they compare object references, not object values. Programmers could find this behavior surprising because autoboxing memoizes, or caches, the values of some primitive variables. Consequently, reference comparisons and value comparisons produce identical results for the subset of values that are memoized.
...