Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The In the absence of autoboxing, the values of boxed primitives cannot be compared using the == and != operators by default. This is because these are interpreted as reference comparison operators. This condition is demonstrated in the first noncompliant code example.

Wiki Markup
Autoboxing on the other hand, can also produce more subtle effects. It works by automatically wrapping the primitive type to the corresponding wrapper object. Some care should be taken during this process, especially when performing comparisons. The Java Language Specification \[[JLS 05|AA. Java References#JLS 05]\] explains this point clearly:

...