yellow racing car with the words code performance

Caching in Wrapper Classes

Here’s a fact that you may not know. When you auto-box integral primitives (byteshortint and long) to their respective wrapper classes (ByteShortInteger 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.

Continue reading