Autoboxing and Auto-Unboxing

Java provides boxing and unboxing conversions to automatically convert between primitivetype values and type-wrapper objects. A boxing conversion converts a value of a primitive type to an object of the corresponding type-wrapper class. An unboxing conversion converts an object of a type-wrapper class to a value of the corresponding primitive type. These conversions are performed automatically (called autoboxing and auto-unboxing), allowing primitive-type values to be used where type-wrapper objects are expected and vice versa.

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.