20 April 2021

Last Time

Other Wrapper Types

We will explore the rest of the wrapper types using jshell. Here is a decoder ring.

PrimitiveWrapper
byteByte
shortShort
intInteger
longLong
floatFloat
doubleDouble
booleanBoolean
charCharacter

Here are common featurs to all wrapper classes.

Here is a use case for one of the parse methods.


import java.util.Scanner;
public class Hoover
{
    public static void main(String[] args)
    {
        Scanner vacuum = new Scanner(System.in);
        System.out.print("Enter a integer:  ");
        String foo = vacuum.next();
        int x = Integer.parseInt(foo);
        System.out.printf("The square of %s is %s.\n", x, x*x);
    }
}