Home Segments Top Top Previous Next

580: Sidetrip

You get information into and out of wrappers as illustrated for the Integer wrapper:

            *-- An int value 
            v 
new Integer(n)          <-- Create a wrapper from the int value 
                            using the new operator 

                *-- A String instance 
                v 
Integer.valueOf(s)      <-- Create a wrapper from the String instance 
                            using a class method 

*-- An Integer instance 
v 
i.intValue()            <-- Obtain embedded int value 
                            using an instance method