Witscale Test Center

13.5 The wrapper classes > 13.5.6 Summary of important methods of wrapper classes in java.lang


13.5.6 Summary of important methods of wrapper classes in java.lang

Though there are plenty of methods associated with wrappers, remembering which one belongs to which wrapper class is easier if you remember the subcategories of wrappers. Six of the eight wrappers are the numeric wrappers.  All numeric wrappers descend from the Number class. The numeric wrappers are further divided into four integral wrappers and two floating-point wrappers. The classes Boolean and Character classes do not fall under the numeric wrapper category and they both have very few methods to be remembered. Table 13.7 summarizes important methods along with the wrappers that define them.

 

Table 13.7 Summary of important methods in wrapper classes

 

 

 

 

Numeric Wrapper classes

 

 

Boolean

Character

Byte

Short

Integer

Long

Float

Double

Instance methods

 

 

ü

ü

ü

ü

ü

ü

byteValue()

 

 

ü

ü

ü

ü

ü

ü

shortValue()

 

 

ü

ü

ü

ü

ü

ü

intValue()

 

 

ü

ü

ü

ü

ü

ü

longValue()

 

 

ü

ü

ü

ü

ü

ü

floatValue()

 

 

ü

ü

ü

ü

ü

ü

doubleValue()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

booleanValue()

ü

 

 

 

 

 

 

 

charValue()

 

ü

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

toString()

ü

ü

ü

ü

ü

ü

ü

ü

 

 

 

 

 

 

 

 

 

Static methods

 

 

 

 

 

 

 

 

parseXxx(primitiveValue)

 

 

ü

ü

ü

ü

ü

ü

parseXxx(primitiveValue, radix)

 

 

ü

ü

ü

ü

 

 

 

 

 

 

 

 

 

 

 

valueOf(string)

ü

 

ü

ü

ü

ü

ü

ü

valueOf(string,radix)

 

 

ü

ü

ü

ü

 

 

 

 

 

 

 

 

 

 

 

toString(primitiveValue)

 

 

ü

ü

ü

ü

ü

ü

toString(primitiveValue, radix)

 

 

 

 

ü

ü

 

 

 

 

 

 

 

 

 

 

 

toHexString(primitiveValue)

 

 

 

 

ü

ü

 

 

toOctalString(primitiveValue)

 

 

 

 

ü

ü

 

 

toBinaryString(primitiveValue)

 

 

 

 

ü

ü

 

 

 

For exam, you need to remember the differences between the three kinds of conversion methods (The instance method xxxValue() and static methods parseXxx(), and valueOf()) and how to use them.