Java Reference
In-Depth Information
Primitive Type
Wrapper Class
byte
Byte
boolean
Boolean
char
Character
double
Double
float
Float
int
Integer
long
Long
short
Short
Note that the wrapper class names start with uppercase letters, and that two of them
differ from the names of the corresponding primitive type: Integer and
Character .
Each wrapper class object contains a value of the corresponding primitive type. For
example, an object of the class Double contains a value of type double (see Figure
5 ).
Wrapper objects can be used anywhere that objects are required instead of primitive
type values. For example, you can collect a sequence of floating-point numbers in an
ArrayList<Double> .
Figure 5
An Object of a Wrapper Class
298
299
Starting with Java version 5.0, conversion between primitive types and the
corresponding wrapper classes is automatic. This process is called auto-boxing (even
though auto-wrapping would have been more consistent).
For example, if you assign a number to a Double object, the number is
automatically Ȓput into a boxȓ, namely a wrapper object.
 
Search WWH ::




Custom Search