Autoboxing

   


Before JDK 5.0, the conversion between primitive types and their wrapper classes was not automatic. To convert from a primitive type to a wrapper object, add a constructor call.

5.0

1.4

Integer wrapper = n;

Integer wrapper = new Integer(n);


To convert a wrapper to a primitive type value, add calls to methods intValue, doubleValue, and so on.

5.0

1.4

int n = wrapper;

int n = wrapper.intValue();



       
    top



    Core Java 2 Volume I - Fundamentals
    Core Java(TM) 2, Volume I--Fundamentals (7th Edition) (Core Series) (Core Series)
    ISBN: 0131482025
    EAN: 2147483647
    Year: 2003
    Pages: 132

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net