Java Reference
In-Depth Information
Here is a sample run:
Ask the Expert
Q :
What else can the primitive type wrapper classes do?
A : The primitive type wrappers provide a number of methods that help integrate the
primitive types into the object hierarchy. For example, various storage mechanisms
provided by the Java library, including maps, lists, and sets, work only with objects.
Thus, to store an int , for example, in a list, it must be wrapped in an object. Also, all
type wrappers have a method called compareTo( ) , which compares the value con-
tained within the wrapper; equals( ) , which tests two values for equality; and meth-
ods that return the value of the object in various forms. The topic of type wrappers is
taken up again in Chapter 12 , when autoboxing is discussed.
Try This 10-2 Creating a Disk-Based Help System
In Try This 4-1 , you created a Help class that displayed information about Java's control
statements. In that implementation, the help information was stored within the class itself,
and the user selected help from a menu of numbered options.
Search WWH ::




Custom Search