Wrapper Type

For each primitive type, there is a corresponding reference type called wrapper type.

Auto-(Un)Boxing: Implicit conversions between wrapper/primitives.

Notice:

  1. Array are never autoboxed/unboxed(an Integer[] cannot be used in place of an int[], or vice versa)
  2. Autoboxing/unboxing incurs a measurable performance impact.
  3. Wrapper types use much more memory than primitive types.

Primitive Widening

Be Care for Ambiguous Conversion

or, call long version:

assertEquals((long)expected, am.get(2));

etc