Skip to content
Justice Tech School

Wrapper Classes and Parsing

Integer, Double and Boolean wrap primitives. parseInt and valueOf convert text.

Example
public class Main {
  public static void main(String[] args) {
    int n = Integer.parseInt("42");
    double d = Double.parseDouble("3.5");
    Integer boxed = n;
    System.out.println(n + 1 + " " + d + " " + boxed.equals(42) + " " + Integer.MAX_VALUE);
  }
}

Result

43 3.5 true 2147483647

Exercise

Parse text.

Integer.("5")

Quiz Test

What does Integer.MAX_VALUE give?

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