THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
Returns the titlecase character equivalent of ch. If there is no titlecase
equivalent, the result of toUpperCase(ch) is returned.

The Character class has many methods to test whether a given character is of a particular type in any
Unicode character set (for example, isDigit recognizes digits in Ethiopic and Khmer). The methods are
passed a char or int code point and return a boolean that answers a question. These methods are:


Method Is the Character...

isDefined a defined Unicode character?

isDigit a digit?

isIdentifierIgnorable ignorable in any identifier (such as a direction control directive)?

isISOControl an ISO control character?

isJavaIdentifierStart valid to start a source code identifier?

isJavaIdentifierPart valid after the first character of a source code identifier?

isLetter a letter?

isLetterOrDigit a letter or digit?

isLowerCase a lowercase letter?

isSpaceChar a space?

isTitleCase a titlecase letter?

isUnicodeIdentifierStart valid to start a Unicode identifier?

isUnicodeIdentifierPart valid after the first character of a Unicode identifier?

isUpperCase an uppercase letter?

isWhitespace a source code whitespace character?

You can also ask whether a char value isLowSurrogate or isHighSurrogate, a specific int code
point isSupplementaryCodePoint or isValidCodePoint, or if a pair of char values
isSurrogatePair.


Unicode identifiers are defined by the Unicode standard. Unicode identifiers must start with a letter
(connecting punctuation such as and currency symbols such as ¥ are not letters in Unicode, although they
are in the Java programming language) and must contain only letters, connecting punctuation (such as
),
digits, numeric letters (such as Roman numerals), combining marks, nonspacing marks, or ignorable control
characters (such as text direction markers).


All these types of characters, and several others, are defined by the Unicode standard. The static method
getType returns an int that defines a character's Unicode type. The return value is one of the following
constants:


COMBINING_SPACING_MARK MODIFIER_LETTER


CONNECTOR_PUNCTUATION MODIFIER_SYMBOL


CONTROL NON_SPACING_MARK

Free download pdf