|
|
|
|
Sometimes it is necessary to pass a primitive type when a (reference to an) object is expected. For example, assume that you have a method that specifies that one of its
arguments is of type
Prior to JSDK 5.0, the above code will produce a compile-time error: "PassIntTest.java": cannot find symbol; symbol :
method valueOf(int), location: The solution is to use a Wrapper class. For every primitive data type, there is a corresponding wrapper class:
Each wrapper class has a constructor which accepts a primitive type value. For example: Integer intWrapper = new Integer(56); The resulting instance "wraps" the supplied value. Note:
|
|
This page was last modified on 02 October, 2007 |