Java - Wrapper Classes
Wrapper Classes
Integer x = 10; // boxing
int y = x;     // unboxing (beware null!)
Use wrappers when generics/collections require reference types, or to represent nullability.
Try it
- Demonstrate NullPointerExceptionfrom unboxing a nullIntegerand then guard against it.
- Store primitives vs wrappers in a list and note the boxing overhead implications.