Wrapper Class (Cont.)


Creating Wrapper Objects
To create a wrapper object, use the wrapper class instead of the primitive type. Since you are now working with objects, you can use certain methods to get information about the specific object. For example, the following methods are used to get the primitive value associated with the corresponding wrapper object: Another useful method is the toString() method, which is used to convert wrapper objects to strings.

Wrapper.java (a wrapper example)
public class Wrapper {
  public static void main( String[ ] args ) {
    Integer myInt = Integer.parseInt( args[0] );
    System.out.print( myInt.intValue( ) + " " );
    System.out.print( myInt + " " );
    String myString = myInt.toString( );
    System.out.print( myString + args[0] );
  }
}
shell> java Wrapper       ⇒     Output:      

        Result: