Java Reference
In-Depth Information
Each of Float , Double , Integer , Long , Short , and Byte provides the other
classes' x Value() methods as well as its own x Value() method. For example,
Float provides doubleValue() , intValue() , longValue() ,
shortValue() , and byteValue() as well as floatValue() .
Allsixmethodsaremembersof Number ,whichistheabstractsuperclassof Float ,
Double , Integer , Long , Short , and Byte Number 's floatValue() ,
doubleValue() , intValue() , and longValue() methods are abstract. Num-
ber is also the superclass of java.math.BigDecimal and
java.math.BigInteger (discussed later in this chapter), and a pair of
concurrency-related classes (one of these classes is presented in Chapter 6 ) .
Number exists to simplify iterating over a collection of Number subclass objects.
For example, you can declare a variable of java.util.List<Number> type and
initialize it to an instance of java.util.ArrayList<Number> (or Ar-
rayList<> , for short). You can then store a mixture of Number subclass objects in
Chapter2 introducedyoutogarbagecollection,whereyoulearnedthatthegarbagecol-
This statement isn't completely true, as you will shortly discover.
Chapter 2 also introduced you to java.lang.Object 's finalize() method,
from the heap. The finalize() method gives the object an opportunity to perform
Thissectioncontinuesfromwhere Chapter2 leftoffbyintroducingyoutoJava'sRe-
API's Reference and ReferenceQueue classes,followedbytheAPI's SoftRe-
ference , WeakReference , and PhantomReference classes. These classes let
applications interact with the garbage collector in limited ways.
Note Aswellasthissection,youwillfindBrianGoetz's“Javatheoryandpractice:
Plugging memory leaks with soft references” (
veloperworks/java/library/j-jtp01246/index.html ) and “Java the-
Search WWH ::

Custom Search