Jump to content

Primitive wrapper class in Java

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Doug Bell (talk | contribs) at 02:30, 23 January 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In the Java programming language a wrapper class is one of eight classes provided in the java.lang package to provide object methods for the eight primitive types. J2SE 5.0 introduced autoboxing of primitive types into their wrapper object, and automatic unboxing of the wrapper objects into their primitive value.

Wrapper classes are used represent primitive values when an Object is required. The wrapper classes are used extensively with Collection classes in the java.util package and with the classes in the java.lang.reflect reflection package.

The wrapper classes and their corresponding primitive types are:

Primitive type Wrapper class
byte Byte
short Short
int Integer
long Long
float Float
double Double
char Character
boolean Boolean

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

See also