Why autobox caching

27 Views Asked by At

I can’t understand why in java there is a special array in the wrapper class, for Example Integer, where wrapper objects for primitives are stored: from -128 to 127. Why a new wrapper object not created for this range, like for other primitives? Does this array optimize the program so much? And why is the range 8 bytes, no more, no less? If someone is familiar with the history of the language, please explain this decision.

0

There are 0 best solutions below