Java Reference
In-Depth Information
8.1. Common Fields and Methods
Except where individually noted, the following sections define construct-
ors, constants, and methods that are defined for each of the wrapper
classes. The general exception is the Void class which supports almost
nothingsee page 187 .
For the constructors and methods that convert strings into values, each
class defines the valid form that the string can take, and these are de-
scribed in the section for each class. For the numeric types, an invalid
string format results in NumberFormatException being thrown.
The term radix, used in several places in the wrapper classes, is another
word for numeric base. For example, decoding a long in radix 8 means
the same as decoding it in base 8. The allowable range for a radix is 2
through 36.
In the following, Type refers to the wrapper class, and type is the corres-
ponding primitive type.
8.1.1. Construction
Each wrapper class defines an immutable object for the primitive value
that it is wrapping. This means that once a wrapper object has been cre-
ated, the value represented by that object can never be changed. So, for
example, the object created by newInteger(1) will always have the value
1, and no methods of class Integer allow you to modify this value.
Each wrapper class has the following constructors:
A constructor that takes a value of the primitive type and creates
an object of the corresponding wrapper class. The constructors
Character(char) and Integer(int) are examples.
 
Search WWH ::




Custom Search