previous | start | next

Wrapper Classes

Each of the basic types has a corresponding "wrapper" class that contains a single data member of the basic type.

Some Java data structures and methods require a class type. In order to use these with basic types, create an instance of the corresponding wrapper class passing the basic value to the constructor.

For example, to "wrap" the basic int value 5:

      Integer N = new Integer(5);

      // N.intValue() is 5. 
   


previous | start | next