Skip to content
Justice Tech School

Wrapper Classes and Autoboxing

Each primitive has a wrapper: Integer, Double, Boolean, Character. Autoboxing converts automatically. Integer.parseInt and Integer.valueOf convert text, and wrappers can be null.

Example
Integer a = 5;
int b = a + 1;
System.out.println(b);
System.out.println(Integer.parseInt("42") + 1);
System.out.println(Integer.MAX_VALUE);
System.out.println(Double.compare(1.5, 2.5));
Integer x = 127, y = 127;
System.out.println(x.equals(y));

Result

6
43
2147483647
-1
true

Exercise

Convert text to int.

Integer.("12")

Quiz Test

Can a wrapper hold null?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.