No. The only wrapper classes that exist are the eight classes in the table, one per each of the eight primitive types.
Here is a program that creates two wrapper objects, then prints out the values they hold. This program could easily be written without wrapper classes. Better uses for wrapper classes will occur later in these chapters.
The toString()
method of the Integer
class is
automatically used when a string of characters is needed in the next to last statement.
The toString()
method of the Double
class is
automatically used when a string of characters is needed last statement.
class WrapperDemo { public static void main ( String[] args ) { Integer value = new Integer( 103 ); // hold the value 103 // inside an Integer object Double dvalue = new Double( -32.78 ); // hold a double precision // value inside a Double object System.out.println( "Integer object holds: " + value ); System.out.println( "Double object holds: " + dvalue ); } }
Was an import
statement needed in this program?