You're building a list of test scores, but List<int> doesn't compile in Java. Collections require objects, not primitives. Wrapper classes like Integer solve this by wrapping primitives in objects.

Integer vs int

Wrapper classes are objects that contain primitive values.

IntegerWrapper.java
Replay: real traced execution (multi-file project)
public class IntegerWrapper {
    public static void main(String[] args) {
        // Primitive
        int primitiveInt = 42;

        // Wrapper object (explicit)
        Integer wrapperInt = Integer.valueOf(42);

        // They work the same in most cases
        System.out.println("Primitive: " + primitiveInt);
        System.out.println("Wrapper: " + wrapperInt);

        // But wrapper is an object with methods
        System.out.println("As hex: " + Integer.toHexString(primitiveInt));
        System.out.println("As binary: " + Integer.toBinaryString(primitiveInt));

        // Comparison
        int a = 5;
        Integer b = 5;
        System.out.println("a == b: " + (a == b));  // Works due to unboxing
    }
}
  1. primitiveInt ← 42, wrapperInt ← 42, a ← 5, b ← 5

    1public class IntegerWrapper {2    public static void main(String[] args) {3        // Primitive4        int primitiveInt→ 42 = 42;5        6        // Wrapper object (explicit)7        Integer wrapperInt→ 42 = Integer.valueOf(42);8        9        // They work the same in most cases10        System.out.println("Primitive: " + primitiveInt42);11        System.out.println("Wrapper: " + wrapperInt42);12        13        // But wrapper is an object with methods14        System.out.println("As hex: " + Integer.toHexString(primitiveInt42));15        System.out.println("As binary: " + Integer.toBinaryString(primitiveInt42));16        17        // Comparison18        int a→ 5 = 5;19        Integer b→ 5 = 5;20        System.out.println("a == b: " + (a5 == b5));  // Works due to unboxing21    }
    outputPrimitive: 42
    Wrapper: 42
    As hex: 2a
    As binary: 101010
    a == b: true

Integer is an object. int is a primitive. Use wrappers when you need objects.

wrapper Object version of a primitive: `Integer`, `Double`, `Boolean`, etc.

Autoboxing and unboxing

Java automatically converts between primitives and wrappers.

Autoboxing.java
Replay: real traced execution (multi-file project)
import java.util.ArrayList;

public class Autoboxing {
    public static void main(String[] args) {
        // Autoboxing: int → Integer (automatic)
        Integer boxed = 100;
        System.out.println("Autoboxed: " + boxed);

        // Unboxing: Integer → int (automatic)
        int unboxed = boxed;
        System.out.println("Unboxed: " + unboxed);

        // Required for collections
        ArrayList<Integer> numbers = new ArrayList<>();
        numbers.add(10);      // autoboxing
        numbers.add(20);
        numbers.add(30);

        int first = numbers.get(0);  // unboxing
        System.out.println("First element: " + first);

        // Sum using unboxing
        int sum = 0;
        for (Integer num : numbers) {
            sum += num;  // unboxing in +=
        }
        System.out.println("Sum: " + sum);


    }
}
  1. boxed ← 100, unboxed ← 100, numbers ← [], first ← 10, sum ← 0

    3public class Autoboxing {4    public static void main(String[] args) {5        // Autoboxing: int → Integer (automatic)6        Integer boxed→ 100 = 100;  //#?autoboxing7        System.out.println("Autoboxed: " + boxed100);8        9        // Unboxing: Integer → int (automatic)10        int unboxed→ 100 = boxed;  //#?unboxing11        System.out.println("Unboxed: " + unboxed100);12        13        // Required for collections14        ArrayList<Integer> numbers→ [] = new ArrayList<>();15        numbers.add(10);      // autoboxing16        numbers.add(20);17        numbers.add(30);18        19        int first→ 10 = numbers.get(0);  // unboxing20        System.out.println("First element: " + first10);21        22        // Sum using unboxing23        int sum→ 0 = 0;24        for (Integer num : numbers) {
    outputAutoboxed: 100
    Unboxed: 100
    First element: 10
  2. sum ← 10

    pass 1 of 3
    23int sum = 0;24for (Integer num10 : numbers[10, 20, 30]) {25    sum→ 10 += num10;  // unboxing in +=26}
    All 3 passes — pass 1 is the card above
    passnumsum
    1100 10
    22010 30
    33030 60
  3. System.out.println("Sum: " + sum);

    26}27System.out.println("Sum: " + sum60);
    outputSum: 60
autoboxing Automatic primitive→wrapper: `Integer x = 5;`
unboxing Automatic wrapper→primitive: `int y = integerObject;`

Parse methods

Wrapper classes provide methods to parse strings.

example
ParseMethods.java
Replay: real traced execution (multi-file project)
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "42";
        String doubleStr = "3.14";
        String boolStr = "true";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "100";
        String doubleStr = "3.14";
        String boolStr = "true";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "-7";
        String doubleStr = "3.14";
        String boolStr = "true";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "42";
        String doubleStr = "2.718";
        String boolStr = "true";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "42";
        String doubleStr = "0.5";
        String boolStr = "true";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "42";
        String doubleStr = "3.14";
        String boolStr = "false";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
public class ParseMethods {
    public static void main(String[] args) {
        // Parse methods from wrapper classes
        String intStr = "42";
        String doubleStr = "3.14";
        String boolStr = "TRUE";

        int intVal = Integer.parseInt(intStr);
        double doubleVal = Double.parseDouble(doubleStr);
        boolean boolVal = Boolean.parseBoolean(boolStr);

        System.out.println("Parsed int: " + intVal);
        System.out.println("Parsed double: " + doubleVal);
        System.out.println("Parsed boolean: " + boolVal);

        // Parse with radix (base)
        String hexStr = "FF";
        String binaryStr = "1010";
        int fromHex = Integer.parseInt(hexStr, 16);
        int fromBinary = Integer.parseInt(binaryStr, 2);
        System.out.println("0xFF = " + fromHex);
        System.out.println("0b1010 = " + fromBinary);

        // valueOf returns wrapper, parseInt returns primitive
        Integer obj = Integer.valueOf("42");
        int prim = Integer.parseInt("42");
    }
}
  1. intStr ← 42, doubleStr ← 3.14, boolStr ← true, intVal ← 42, doubleVal ← 3.14

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 42 = "42";        //@intStr="100", "-7"5        String doubleStr→ 3.14 = "3.14";   //@doubleStr="2.718", "0.5"6        String boolStr→ true = "true";     //@boolStr="false", "TRUE"7        8        int intVal→ 42 = Integer.parseInt(intStr42);9        double doubleVal→ 3.14 = Double.parseDouble(doubleStr3.14);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrtrue);11        12        System.out.println("Parsed int: " + intVal42);13        System.out.println("Parsed double: " + doubleVal3.14);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 42
    Parsed double: 3.14
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10
  1. intStr ← 100, doubleStr ← 3.14, boolStr ← true, intVal ← 100, doubleVal ← 3.14

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 100 = "100";5        String doubleStr→ 3.14 = "3.14";6        String boolStr→ true = "true";7        8        int intVal→ 100 = Integer.parseInt(intStr100);9        double doubleVal→ 3.14 = Double.parseDouble(doubleStr3.14);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrtrue);11        12        System.out.println("Parsed int: " + intVal100);13        System.out.println("Parsed double: " + doubleVal3.14);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 100
    Parsed double: 3.14
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10
  1. intStr ← -7, doubleStr ← 3.14, boolStr ← true, intVal ← -7, doubleVal ← 3.14

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ -7 = "-7";5        String doubleStr→ 3.14 = "3.14";6        String boolStr→ true = "true";7        8        int intVal→ -7 = Integer.parseInt(intStr-7);9        double doubleVal→ 3.14 = Double.parseDouble(doubleStr3.14);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrtrue);11        12        System.out.println("Parsed int: " + intVal-7);13        System.out.println("Parsed double: " + doubleVal3.14);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: -7
    Parsed double: 3.14
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10
  1. intStr ← 42, doubleStr ← 2.718, boolStr ← true, intVal ← 42, doubleVal ← 2.718

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 42 = "42";5        String doubleStr→ 2.718 = "2.718";6        String boolStr→ true = "true";7        8        int intVal→ 42 = Integer.parseInt(intStr42);9        double doubleVal→ 2.718 = Double.parseDouble(doubleStr2.718);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrtrue);11        12        System.out.println("Parsed int: " + intVal42);13        System.out.println("Parsed double: " + doubleVal2.718);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 42
    Parsed double: 2.718
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10
  1. intStr ← 42, doubleStr ← 0.5, boolStr ← true, intVal ← 42, doubleVal ← 0.5

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 42 = "42";5        String doubleStr→ 0.5 = "0.5";6        String boolStr→ true = "true";7        8        int intVal→ 42 = Integer.parseInt(intStr42);9        double doubleVal→ 0.5 = Double.parseDouble(doubleStr0.5);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrtrue);11        12        System.out.println("Parsed int: " + intVal42);13        System.out.println("Parsed double: " + doubleVal0.5);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 42
    Parsed double: 0.5
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10
  1. intStr ← 42, doubleStr ← 3.14, boolStr ← false, intVal ← 42, doubleVal ← 3.14

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 42 = "42";5        String doubleStr→ 3.14 = "3.14";6        String boolStr→ false = "false";7        8        int intVal→ 42 = Integer.parseInt(intStr42);9        double doubleVal→ 3.14 = Double.parseDouble(doubleStr3.14);10        boolean boolVal→ false = Boolean.parseBoolean(boolStrfalse);11        12        System.out.println("Parsed int: " + intVal42);13        System.out.println("Parsed double: " + doubleVal3.14);14        System.out.println("Parsed boolean: " + boolValfalse);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 42
    Parsed double: 3.14
    Parsed boolean: false
    0xFF = 255
    0b1010 = 10
  1. intStr ← 42, doubleStr ← 3.14, boolStr ← TRUE, intVal ← 42, doubleVal ← 3.14

    1public class ParseMethods {2    public static void main(String[] args) {3        // Parse methods from wrapper classes4        String intStr→ 42 = "42";5        String doubleStr→ 3.14 = "3.14";6        String boolStr→ TRUE = "TRUE";7        8        int intVal→ 42 = Integer.parseInt(intStr42);9        double doubleVal→ 3.14 = Double.parseDouble(doubleStr3.14);10        boolean boolVal→ true = Boolean.parseBoolean(boolStrTRUE);11        12        System.out.println("Parsed int: " + intVal42);13        System.out.println("Parsed double: " + doubleVal3.14);14        System.out.println("Parsed boolean: " + boolValtrue);15        16        // Parse with radix (base)17        String hexStr→ FF = "FF";18        String binaryStr→ 1010 = "1010";19        int fromHex→ 255 = Integer.parseInt(hexStrFF, 16);20        int fromBinary→ 10 = Integer.parseInt(binaryStr1010, 2);21        System.out.println("0xFF = " + fromHex255);22        System.out.println("0b1010 = " + fromBinary10);23        24        // valueOf returns wrapper, parseInt returns primitive25        Integer obj→ 42 = Integer.valueOf("42");26        int prim→ 42 = Integer.parseInt("42");27    }
    outputParsed int: 42
    Parsed double: 3.14
    Parsed boolean: true
    0xFF = 255
    0b1010 = 10

Integer.parseInt(), Double.parseDouble() - these come from wrapper classes.

Null handling

Unlike primitives, wrapper objects can be null - useful but requires care.

Null.java
Replay: real traced execution (multi-file project)
public class Null {
    public static void main(String[] args) {
        // Wrapper can be null (primitive cannot)
        Integer maybeAge = null;     // Unknown age
        // int age = null;           // ERROR: won't compile

        // Check before using
        if (maybeAge != null) {
            System.out.println("Age: " + maybeAge);
        } else {
            System.out.println("Age unknown");
        }

        // NullPointerException danger!
        Integer quantity = null;
        // int q = quantity;  // Runtime error: NullPointerException

        // Safe unboxing
        int safeQuantity = (quantity != null) ? quantity : 0;
        System.out.println("Safe quantity: " + safeQuantity);

        // Practical: optional values
        Integer[] scores = {85, null, 92, null, 78};
        int count = 0;
        int total = 0;
        for (Integer score : scores) {
            if (score != null) {
                total += score;
                count++;
            }
        }
        System.out.println("Average (excluding missing): " + (total / count));

    }
}
  1. maybeAge ← null

    1public class Null {2    public static void main(String[] args) {3        // Wrapper can be null (primitive cannot)4        Integer maybeAge→ null = null;     // Unknown age5        // int age = null;           // ERROR: won't compile
  2. else

    9    System.out.println("Age: " + maybeAge);10} else {11    System.out.println("Age unknown");12}
    outputAge unknown
  3. quantity ← null, safeQuantity ← 0, count ← 0, total ← 0

    14// NullPointerException danger!15Integer quantity→ null = null;16// int q = quantity;  // Runtime error: NullPointerException1718// Safe unboxing19int safeQuantity→ 0 = (quantitynull != null) ? quantity : 0;20System.out.println("Safe quantity: " + safeQuantity0);2122// Practical: optional values23Integer[] scores = {85, null, 92, null, 78};  //#?null_scores24int count→ 0 = 0;25int total→ 0 = 0;26for (Integer score : scores) {
    outputSafe quantity: 0
  4. for (Integer score : scores)

    pass 1 of 5
    25int total = 0;26for (Integer score85 : scores) {27    if (score != null) {
    All 5 passes — pass 1 is the card above
    passscore
    185
    2null
    392
    4null
    578
  5. total ← 85, count ← 1

    pass 1 of 3
    26for (Integer score : scores) {27    if (score85 != null) {28        total→ 85 += score85;29        count→ 1++;30    }
    All 3 passes — pass 1 is the card above
    passscoretotalcount
    1850 850 1
    29285 1771 2
    378177 2552 3
  6. System.out.println("Average (excluding missing): " + (total / count));

    31}32System.out.println("Average (excluding missing): " + (total255 / count3));
    outputAverage (excluding missing): 85
null Wrappers can be null (no value). Primitives cannot.

Useful methods

Wrapper classes provide utility methods beyond conversion.

example
Utilities.java
Replay: real traced execution (multi-file project)
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 10;
        int b = 20;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = 'A';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 5;
        int b = 20;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = 'A';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 100;
        int b = 20;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = 'A';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 10;
        int b = 50;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = 'A';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 10;
        int b = 20;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = 'a';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
public class Utilities {
    public static void main(String[] args) {
        // Constants
        System.out.println("=== Integer Constants ===");
        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);
        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);
        System.out.println("BYTES: " + Integer.BYTES);

        // Comparison
        int a = 10;
        int b = 20;
        System.out.println("\n=== Comparison ===");
        System.out.println("max(" + a + ", " + b + "): " + Integer.max(a, b));
        System.out.println("min(" + a + ", " + b + "): " + Integer.min(a, b));
        System.out.println("compare(" + a + ", " + b + "): " + Integer.compare(a, b));

        // Unsigned operations
        System.out.println("\n=== Unsigned ===");
        int negative = -1;
        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative));

        // Character utilities
        System.out.println("\n=== Character ===");
        char c = '7';
        System.out.println("isDigit('" + c + "'): " + Character.isDigit(c));
        System.out.println("isLetter('" + c + "'): " + Character.isLetter(c));
        System.out.println("isUpperCase('" + c + "'): " + Character.isUpperCase(c));
        System.out.println("toLowerCase('" + c + "'): " + Character.toLowerCase(c));
    }
}
  1. a ← 10, b ← 20, negative ← -1, c ← A

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 10 = 10;   //@a=5, 10011        int b→ 20 = 20;   //@b=20, 5012        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a10 + ", " + b20 + "): " + Integer.max(a, b));14        System.out.println("min(" + a10 + ", " + b20 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a10 + ", " + b20 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ A = 'A';   //@c='a', '7'25        System.out.println("isDigit('" + cA + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + cA + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + cA + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + cA + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(10, 20): 20
    min(10, 20): 10
    compare(10, 20): -1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('A'): false
    isLetter('A'): true
    isUpperCase('A'): true
    toLowerCase('A'): a
  1. a ← 5, b ← 20, negative ← -1, c ← A

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 5 = 5;11        int b→ 20 = 20;12        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a5 + ", " + b20 + "): " + Integer.max(a, b));14        System.out.println("min(" + a5 + ", " + b20 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a5 + ", " + b20 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ A = 'A';25        System.out.println("isDigit('" + cA + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + cA + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + cA + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + cA + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(5, 20): 20
    min(5, 20): 5
    compare(5, 20): -1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('A'): false
    isLetter('A'): true
    isUpperCase('A'): true
    toLowerCase('A'): a
  1. a ← 100, b ← 20, negative ← -1, c ← A

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 100 = 100;11        int b→ 20 = 20;12        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a100 + ", " + b20 + "): " + Integer.max(a, b));14        System.out.println("min(" + a100 + ", " + b20 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a100 + ", " + b20 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ A = 'A';25        System.out.println("isDigit('" + cA + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + cA + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + cA + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + cA + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(100, 20): 100
    min(100, 20): 20
    compare(100, 20): 1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('A'): false
    isLetter('A'): true
    isUpperCase('A'): true
    toLowerCase('A'): a
  1. a ← 10, b ← 50, negative ← -1, c ← A

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 10 = 10;11        int b→ 50 = 50;12        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a10 + ", " + b50 + "): " + Integer.max(a, b));14        System.out.println("min(" + a10 + ", " + b50 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a10 + ", " + b50 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ A = 'A';25        System.out.println("isDigit('" + cA + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + cA + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + cA + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + cA + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(10, 50): 50
    min(10, 50): 10
    compare(10, 50): -1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('A'): false
    isLetter('A'): true
    isUpperCase('A'): true
    toLowerCase('A'): a
  1. a ← 10, b ← 20, negative ← -1, c ← a

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 10 = 10;11        int b→ 20 = 20;12        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a10 + ", " + b20 + "): " + Integer.max(a, b));14        System.out.println("min(" + a10 + ", " + b20 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a10 + ", " + b20 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ a = 'a';25        System.out.println("isDigit('" + ca + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + ca + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + ca + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + ca + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(10, 20): 20
    min(10, 20): 10
    compare(10, 20): -1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('a'): false
    isLetter('a'): true
    isUpperCase('a'): false
    toLowerCase('a'): a
  1. a ← 10, b ← 20, negative ← -1, c ← 7

    1public class Utilities {2    public static void main(String[] args) {3        // Constants4        System.out.println("=== Integer Constants ===");5        System.out.println("MAX_VALUE: " + Integer.MAX_VALUE);6        System.out.println("MIN_VALUE: " + Integer.MIN_VALUE);7        System.out.println("BYTES: " + Integer.BYTES);8        9        // Comparison10        int a→ 10 = 10;11        int b→ 20 = 20;12        System.out.println("\n=== Comparison ===");13        System.out.println("max(" + a10 + ", " + b20 + "): " + Integer.max(a, b));14        System.out.println("min(" + a10 + ", " + b20 + "): " + Integer.min(a, b));15        System.out.println("compare(" + a10 + ", " + b20 + "): " + Integer.compare(a, b));16        17        // Unsigned operations18        System.out.println("\n=== Unsigned ===");19        int negative→ -1 = -1;20        System.out.println("-1 as unsigned: " + Integer.toUnsignedString(negative-1));21        22        // Character utilities23        System.out.println("\n=== Character ===");24        char c→ 7 = '7';25        System.out.println("isDigit('" + c7 + "'): " + Character.isDigit(c));26        System.out.println("isLetter('" + c7 + "'): " + Character.isLetter(c));27        System.out.println("isUpperCase('" + c7 + "'): " + Character.isUpperCase(c));28        System.out.println("toLowerCase('" + c7 + "'): " + Character.toLowerCase(c));29    }
    output=== Integer Constants ===
    MAX_VALUE: 2147483647
    MIN_VALUE: -2147483648
    BYTES: 4
    
    === Comparison ===
    max(10, 20): 20
    min(10, 20): 10
    compare(10, 20): -1
    
    === Unsigned ===
    -1 as unsigned: 4294967295
    
    === Character ===
    isDigit('7'): true
    isLetter('7'): false
    isUpperCase('7'): false
    toLowerCase('7'): 7

max(), min(), compare(), constants like MAX_VALUE - all from wrappers.

Exercise: AllWrappers.java

Explore all wrapper classes: Boolean, Byte, Short, Integer, Long, Float, Double, Character