Grey may
Grey may

Reputation: 3

Why autobox caching

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.

Upvotes: 0

Views: 25

Answers (0)

Related Questions