Java Reference
In-Depth Information
Long , Float , and Double also define useful constants and methods. For ex-
ample, most wrapper classes declare constants MIN_VALUE and MAX_VALUE
that hold the minimum and maximum values for the associated primitive
type.
The Float and Double classes also have NaN , NEGATIVE_INFINITY , and
POSITIVE_INFINITY constants. Both also provide an isNaN method that
tests whether a floating-point value is "Not a Number"that is, whether it
is the result of a floating-point expression that has no valid result, such
as dividing zero by zero. The NaN value can be used to indicate an invalid
floating-point value; this is similar to the use of null for object referen-
ces that do not refer to anything. The wrapper classes are covered in
detail in Chapter 8 .
There is no unsigned integer type. If you need to work with unsigned
values originating outside your program, they must be stored in a larger
signed type. For example, unsigned bytes produced by an analog-to-di-
gital converter, can be read into variables of type short .
The reference types are class types, interface types, and array types.
Variables of these types can refer to objects of the corresponding type.
Each type has literals, which are the way that constant values of that
type are written. The next few subsections describe how literal (un-
named) constants for each type are specified.
7.2.1. Reference Literals
The only literal object reference is null . It can be used anywhere a ref-
erence is expected. Conventionally, null represents an invalid or uncre-
ated object. It has no class, not even Object , but null can be assigned
to any reference variable.
7.2.2. Boolean Literals
The boolean literals are true and false .
 
Search WWH ::




Custom Search