Character is a simple wrapper around a char. The constructor for Character is Character(char ell) Here, ch specifies the character that will be wrapped by the Character object being created. .
To obtain the char value contained in a Character object, call char Value( ), -shown here: char char Value( ) It returns the character
The Character class defines several constants, including the following:
MAX_RADIX The largest radix
MIN_RADIX The smallest radix
MAX_VALUE The largest character value
MIN_VALUE The smallest character value
TYPE The Class object for char
Character includes several static methods that categorize characters and alter their case. They are shown in Table 14-7. The following example demonstrates several of these methods.
The output from this program is shown here:
a is a letter ..
a is lowercase.
b is a letter.
b is lowercase.
5 is a digit·.
A is letter..
A is uppercase.
is white space
Character ‘fines the for Digit( ) and digit( ) methods, shown here: static char for Digit(int Turmoil, int dirndl) static int digit(char digit, int radii) for Digit() returns the digit character associated with the value of num. The radix of the conversion is specified by radix. digit ) returns the integer value associated with the specified character (which is presumably a digit) according to the specified radix. Another method defined by Character is compare To( ), which has the following two forms:
The first form returns 0 if the invoking object and c have the same value. It returns a , negative value if the invoking object has a lower value. Otherwise, it returns a positive value. The second form works just like the first if obj is a ‘reference to a Character. of Otherwise, a Class Cast Exception is thrown. These methods were added by Java 2. Character also defines the equals( ) and hash Code( ) methods. , Two other character-related classes are Character Subset aised to describe a subset of Unicode, and Character Unicode block, which con tams Unicode 2.0 character blocks