Here’s a fact that you may not know. When you auto-box integral primitives (byte
, short
, int
and long
) to their respective wrapper classes (Byte
, Short
, Integer
and Long
), the wrapper classes cache all values from -128
to +127
. These values are later used by the valueOf()
methods to give better performance than using a constructor.
