Memra

Wrapper classes, autoboxing & parsing

Treating primitives as objects, and turning text into numbers.

Every primitive has an object twin

Each primitive has a wrapper class: intInteger, doubleDouble, booleanBoolean, charCharacter, and so on. Wrappers are needed wherever an object is required — most importantly in collections, which can't hold raw primitives (List<Integer>, never List<int>).

Autoboxing converts automatically in both directions:

Integer boxed = 5;      // autobox: int → Integer
int back = boxed;        // unbox: Integer → int
List<Integer> nums = new ArrayList<>();
nums.add(42);            // autoboxed

Parsing turns a String into a number via the wrapper's static method:

int n = Integer.parseInt("42");
double d = Double.parseDouble("3.14");

Wrappers also expose useful constants and helpers: Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.toBinaryString(n).

NORMAL ~/memra/learn/java-from-zero/wrappers-and-parsing utf-8 LF