Java Reference
In-Depth Information
•
A constructor that converts a single
String
parameter into the ob-
ject's initial value (except
Character
, which has no such construct-
or)for example,
newFloat("6.02e23")
.
Each wrapper class,
Type
, also has the following methods:
public static
Type
valueOf(
type
t)
Returns an object of the specified
Type
with the value
t
.
public static
Type
valueOf(String str)
Returns an object of the specified
Type
with the value parsed
from
str
.
Float.valueOf("6.02e23")
and
Integer.valueOf("16")
are examples.
Character
does not have this method just as it
does not have the string-converting constructor.
These methods may return a newly constructed instance or a cached
instance. For efficiency, you should always use one of the
valueOf
meth-
ods, in preference to direct construction, unless you really need distinct
instances that have the same value.
8.1.2. Constants
Each of the wrapper classes, with the exception of
Boolean
define the fol-
lowing three fields:
public static final
type
MIN_VALUE
The minimum value representable by this data type. For ex-
ample, for
Integer
this is 2
31
.
public static final
type
MAX_VALUE