Friday, August 1, 2008

Know wrapper class more

A primitive wrapper class in the java programing language is one of eight classes provided in the java.lang package to provide object method to the eight primitive types. All of the primitive wrapper classes in Java are immutable. J2SE 5.0 introduced autoboxing of primitive types into their wrapper object, and automatic unboxing of the wrapper objects into their primitive value—the implicit conversion between the wrapper objects and primitive values.

Wrapper class is used to represent primitive values when an object is required. The wrapper classes are used extensively with collection classes in the java.utill package and with the classes in the reflection package

The primitive wrapper classes and their corresponding primitive types are:

Primitive type Wrapper class Constructor Arguments
byte
byte or String
short
short or String
int
int or String
long
long or String
float
float, double or String
double
double or String
char
char
boolean
boolean or String

The Byte, Short, Integer, Long, Float, and Double wrapper classes are all subclass of the Number class



0 comments: