java.lang · java.base · since Java 1.0

Integer

declaration
public final class Integer extends Number
        implements Comparable<Integer>, Constable

Immutable box for int, plus the static utility home for parsing, comparing, and bit-twiddling ints. Autoboxing caches −128…127 — the root of famous == surprises.

Key methods

static int parseInt(String s)String → int; NumberFormatException on garbage.
static Integer valueOf(int i)Boxing entry — cached for −128…127.
static int compare(int a, int b)Overflow-safe comparison (never a - b).
static int max/min/sum(int, int)Method-reference-friendly arithmetic.
static String toBinaryString/toHexString(int)Radix views.
static int bitCount(int) / highestOneBit(int)Bit tricks, JIT-intrinsified.
MIN_VALUE / MAX_VALUE−2³¹ and 2³¹−1 constants.