Java The Complete Reference, Seventh Edition

(Greg DeLong) #1
Characterdefines two methods,forDigit( )anddigit( ), that enable you to convert
between integer values and the digits they represent. They are shown here:

static char forDigit(intnum, intradix)
static int digit(chardigit, intradix)

forDigit( )returns the digit character associated with the value ofnum.The radix of the
conversion is specified byradix.digit( )returns the integer value associated with the specified
character (which is presumably a digit) according to the specified radix.
Another method defined byCharacteriscompareTo( ), which has the following form:

int compareTo(Characterc)

It returns zero if the invoking object andchave the same value. It returns a negative value
if the invoking object has a lower value. Otherwise, it returns a positive value.
Characterincludes a method calledgetDirectionality( )which can be used to determine
the direction of a character. Several constants are defined that describe directionality.Most programs
will not need to use character directionality.
Characteralso overrides theequals( )andhashCode( )methods.
Two other character-related classes areCharacter.Subset, used to describe a subset of
Unicode, andCharacter.UnicodeBlock, which contains Unicode character blocks.

400 Part II: The Java Library


Method Description
static boolean isMirrored(charch) Returnstrueifchis a mirrored Unicode character.
A mirrored character is one that is reversed for text
that is displayed right-to-left.
static boolean isSpaceChar(charch) Returnstrueifchis a Unicode space character.
Other wise, it returnsfalse.
static boolean isTitleCase(charch) Returnstrueifchis a Unicode titlecase character.
Other wise, it returnsfalse.
static boolean
isUnicodeIdentifierPart(charch)

Returnstrueifchis allowed as part of a Unicode
identifier (other than the first character).
Other wise, it returnsfalse.
static boolean
isUnicodeIdentifierStart(charch)

Returnstrueifchis allowed as the first character
of a Unicode identifier. Other wise, it returnsfalse.
static boolean isUpperCase(charch) Returnstrueifchis an uppercase letter.
Other wise, it returnsfalse.
static boolean isWhitespace(charch) Returnstrueifchis whitespace. Other wise, it
returnsfalse.
static char toLowerCase(charch) Returns lowercase equivalent ofch.
static char toTitleCase(charch) Returns titlecase equivalent ofch.
static char toUpperCase(charch) Returns uppercase equivalent ofch.

TABLE 16-7 VariousCharacterMethods(continued)
Free download pdf