Skip to main content

What are wrapper classes and autoboxing/unboxing?

Entry Java
Quick Answer Wrapper classes (Integer, Double, Boolean etc.) wrap primitive types as objects so they can be used in collections and generics. Autoboxing: automatic conversion from primitive to wrapper (int to Integer). Unboxing: automatic conversion from wrapper to primitive. Watch out: unboxing a null Integer throws NullPointerException. Autoboxing in loops can create many short-lived objects.

Answer

Wrapper classes represent primitive types as objects.
Autoboxing: primitive ? wrapper.
Unboxing: wrapper ? primitive.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice