wrapper class

A class, such as Integer for int, that wraps a primitive value in an object so it can be stored in collections or be null.

In more detail

Every primitive has one: Integer, Long, Double, Boolean, Character and so on. Because a wrapper is a reference type it can be null, and unboxing a null wrapper throws NullPointerException. Keep primitives in numeric code and use wrappers where an object is required.

Example

Integer boxed = 42;

Related terms

Taught in

References

Certification courses