Java Autoboxing

From NovaOrdis Knowledge Base
Revision as of 18:16, 28 March 2018 by Ovidiu (talk | contribs) (Ovidiu moved page Java Autoboxing and Unboxing to Java Autoboxing)
Jump to navigation Jump to search

Internal

Overview

Java has a mechanism called boxing that converts primitive types (such as int) into their corresponding reference types (java.lang.Integer). The opposite operation, converting reference types into their corresponding primitive types is called unboxing.

Autoboxing is a mechanism that performs boxing and unboxing automatically.

Autoboxing comes with a performance cost. Boxed values are wrappers around primitive types, and are stored on the heap. Therefore, boxed values use more memory and requires additional memory lookups to fetch the wrapped primitive type.

TODO