Class java.lang.Character
All Packages Class Hierarchy This Package Previous Next Index
Class java.lang.Character
java.lang.Object
|
+----java.lang.Character
- public final class Character
- extends Object
The Character class provides an object wrapper for Character data values
and serves as a place for character-oriented operations. A wrapper is useful
because most of Java's utility classes require the use of objects. Since characters
are not objects in Java, they need to be "wrapped" in a Character instance.
- MAX_RADIX
- The maximum radix available for conversion to and from Strings.
- MAX_VALUE
- The maximum value a Character can have.
- MIN_RADIX
- The minimum radix available for conversion to and from Strings.
- MIN_VALUE
- The minimum value a Character can have.
- Character(char)
- Constructs a Character object with the specified value.
- charValue()
- Returns the value of this Character object.
- digit(char, int)
- Returns the numeric value of the character digit using the specified
radix.
- equals(Object)
- Compares this object against the specified object.
- forDigit(int, int)
- Returns the character value for the specified digit in the specified
radix.
- hashCode()
- Returns a hashcode for this Character.
- isDefined(char)
- Determines whether the specified character actually has a Unicode definition.
- isDigit(char)
- Determines whether the specified character is a digit.
- isJavaLetter(char)
- Determines whether the specified character is a "Java" letter,
that is, permissible as the first character in a Java identifier.
- isJavaLetterOrDigit(char)
- Determines whether the specified character is a "Java" letter or digit,
that is, permissible as a non-initial character in a Java identifier.
- isLetter(char)
- Determines whether the specified character is a letter.
- isLetterOrDigit(char)
- Determines whether the specified character is a letter or digit.
- isLowerCase(char)
- Determines whether the specified character is a lowercase character.
- isSpace(char)
- Determines if the specified character is ISO-LATIN-1 white space according to Java.
- isTitleCase(char)
- Determines whether the specified character is a titlecase character.
- isUpperCase(char)
- Determines whether the specified character is an uppercase character.
- toLowerCase(char)
- The given character is mapped to its lowercase equivalent;
if the character has no lowercase equivalent, the character itself is returned.
- toString()
- Returns a String object representing this character's value.
- toTitleCase(char)
- The given character is mapped to its titlecase equivalent;
if the character has no titlecase equivalent, the character itself is returned.
- toUpperCase(char)
MIN_RADIX
public final static int MIN_RADIX
- The minimum radix available for conversion to and from Strings. The minimum value that a radix can be is 2.
- See Also:
- toString
MAX_RADIX
public final static int MAX_RADIX
- The maximum radix available for conversion to and from Strings. The
maximum value that a radix can be is 36.
- See Also:
- toString
MIN_VALUE
public final static char MIN_VALUE
- The minimum value a Character can have. The lowest minimum value a
Character can have is \u0000.
MAX_VALUE
public final static char MAX_VALUE
- The maximum value a Character can have. The greatest maximum value a
Character can have is \uffff.
Character
public Character(char value)
- Constructs a Character object with the specified value.
- Parameters:
- value - value of this Character object
isLowerCase
public static boolean isLowerCase(char ch)
- Determines whether the specified character is a lowercase character.
A character is considered to be lowercase if and only if all
of the following are true:
- The character is not in the range 0x2000 through 0x2FFF.
- The Unicode 1.1.5 attribute table does not specify a mapping to lowercase for the character.
- At least one of the following is true:
- The Unicode 1.1.5 attribute table does specify a mapping to uppercase for the character.
- The Unicode 1.1.5 name for the character contains the words "SMALL LETTER".
- The Unicode 1.1.5 name for the character contains the words "SMALL LIGATURE".
Of the ISO-LATIN-1 characters (character codes 0x0000 through 0x00FF),
the following are lowercase:
a b c d e f g h i j k l m n o p q r s t u v w x y z
ß à á â ã ä å æ ç
è é ê ë ì í î ï ð
ñ ò ó ô õ ö ø ù ú
û ü ý þ ÿ - Parameters:
- ch - the character to be tested
- Returns:
- true if the character is lowercase; false otherwise.
- See Also:
- isUpperCase, isTitleCase, toLowerCase
isUpperCase
public static boolean isUpperCase(char ch)
- Determines whether the specified character is an uppercase character.
A character is considered to be uppercase if and only if all
of the following are true:
- The character is not in the range 0x2000 through 0x2FFF.
- The Unicode 1.1.5 attribute table does not specify a mapping to uppercase for the character.
- At least one of the following is true:
- The Unicode 1.1.5 attribute table does specify a mapping to lowercase for the character.
- The Unicode 1.1.5 name for the character contains the words "CAPITAL LETTER".
- The Unicode 1.1.5 name for the character contains the words "CAPITAL LIGATURE".
Of the ISO-LATIN-1 characters (character codes 0x0000 through 0x00FF),
the following are uppercase:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
À Á Â Ã Ä Å Æ Ç
È É Ê Ë Ì Í Î Ï Ð
Ñ Ò Ó Ô Õ Ö Ø Ù Ú
Û Ü Ý Þ - Parameters:
- ch - the character to be tested
- Returns:
- true if the character is uppercase; false otherwise.
- See Also:
- isLowerCase, isTitleCase, toUpperCase
isTitleCase
public static boolean isTitleCase(char ch)
- Determines whether the specified character is a titlecase character.
A character is considered to be titlecase if and only if all
of the following are true:
- The character is not in the range 0x2000 through 0x2FFF.
- The Unicode 1.1.5 attribute table does specify a mapping to uppercase for the character.
- The Unicode 1.1.5 attribute table does specify a mapping to lowercase for the character.
The basic idea is that there are a few Unicode characters
whose printed representations look like pairs of Latin
letters. For example, there is an uppercase letter that
looks like "LJ" and the corresponding lowercase letter looks
like "lj". These letters have a third form, a titlecase
form, that looks like "Lj". This is the appropriate form
to use when rendering a word in lowercase with initial
capitals, as for a book title. There are exactly four Unicode characters for which this method
returns true:
- Å
- LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
- È
- LATIN CAPITAL LETTER L WITH SMALL LETTER J
- Ë
- LATIN CAPITAL LETTER N WITH SMALL LETTER J
- ò
- LATIN CAPITAL LETTER D WITH SMALL LETTER Z
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is titlecase; false otherwise.
- See Also:
- isUpperCase, isLowerCase, toTitleCase
isDigit
public static boolean isDigit(char ch)
- Determines whether the specified character is a digit.
A character is considered to be a digit if and only if both
of the following are true:
- The character is not in the range 0x2000 through 0x2FFF.
- The Unicode 1.1.5 name for the character contains the word "DIGIT".
These are the ranges of Unicode characters that are considered digits: - 0x0030 through 0x0039
- ISO-LATIN-1 digits ('0' through '9')
- 0x0660 through 0x0669
- Arabic-Indic digits
- 0x06F0 through 0x06F9
- Extended Arabic-Indic digits
- 0x0966 through 0x096F
- Devanagari digits
- 0x09E6 through 0x09EF
- Bengali digits
- 0x0A66 through 0x0A6F
- Gurmukhi digits
- 0x0AE6 through 0x0AEF
- Gujarati digits
- 0x0B66 through 0x0B6F
- Oriya digits
- 0x0BE7 through 0x0BEF
- Tamil digits
- 0x0C66 through 0x0C6F
- Telugu digits
- 0x0CE6 through 0x0CEF
- Kannada digits
- 0x0D66 through 0x0D6F
- Malayalam digits
- 0x0E50 through 0x0E59
- Thai digits
- 0x0ED0 through 0x0ED9
- Lao digits
- 0xFF10 through 0xFF19
- Fullwidth digits
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is a digit; false otherwise.
- See Also:
- digit, forDigit
isDefined
public static boolean isDefined(char ch)
- Determines whether the specified character actually has a Unicode definition.
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character has a defined meaning in Unicode 1.1.5; false otherwise.
- See Also:
- isDigit, isLetter, isLetterOrDigit, isUpperCase, isLowerCase, isTitleCase
isLetter
public static boolean isLetter(char ch)
- Determines whether the specified character is a letter.
A character is considered to be a letter if and only if
is it a "letter or digit" but is not a "digit".
Note that not all letters have case: many Unicode characters are
letters but are neither uppercase nor lowercase nor titlecase.
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is a letter; false otherwise.
- See Also:
- isDigit, isLetterOrDigit, isJavaLetter, isJavaLetterOrDigit, isUpperCase, isLowerCase, isTitleCase
isLetterOrDigit
public static boolean isLetterOrDigit(char ch)
- Determines whether the specified character is a letter or digit.
These are the ranges of Unicode characters that are considered to be letters or digits:
- 0x0030 through 0x0039
- ISO-LATIN-1 digits ('0' through '9')
- 0x0041 through 0x005A
- ISO-LATIN-1 uppercase Latin letters ('A' through 'Z')
- 0x0061 through 0x007A
- ISO-LATIN-1 lowercase Latin letters ('A' through 'Z')
- 0x00C0 through 0x00D6, 0x00D8 through 0x00F6, and 0x00F8 through 0x00FF
- ISO-LATIN-1 supplementary letters
- 0x0100 through 0x1FFF, but only if there is an entry in the Unicode 1.1.5 table
- Latin extended-A, Latin extended-B, IPA extensions, spacing modifier letters, combining diacritical marks, basic Greek, Greek symbols and Coptic, Cyrillic, Armenian, Hebrew extended-A, Basic Hebrew, Hebrew extended-B, Basic Arabic, Arabic extended, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Thai, Lao, Basic Georgian, Georgian extended, Hanguljamo, Latin extended additional, Greek extended
- 0x3040 through 0x9FA5
- Hiragana, Katakana, Bopomofo, Hangul compatibility Jamo, CJK miscellaneous, enclosed CJK characters and months, CJK compatibility, Hangul, Hangul supplementary-A, Hangul supplementary-B, CJK unified ideographs
- 0xF900 through 0xFA2D
- CJK compatibility ideographs
- 0xFB00 through 0xFDFF, but only if there is an entry in the Unicode 1.1.5 table
- alphabetic presentation forms, Arabic presentation forms-A
- 0xFE70 through 0xFEFE, but only if there is an entry in the Unicode 1.1.5 table
- Arabic presentation forms-B
- 0xFF10 through 0xFF19
- Fullwidth digits
- 0xFF21 through 0xFF3A
- Fullwidth Latin uppercase
- 0xFF41 through 0xFF5A
- Fullwidth Latin lowercase
- 0xFF66 through 0xFFDC
- Halfwidth Katakana and Hangul
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is a letter or digit; false otherwise.
- See Also:
- isDigit, isLetter, isJavaLetter, isJavaLetterOrDigit
isJavaLetter
public static boolean isJavaLetter(char ch)
- Determines whether the specified character is a "Java" letter,
that is, permissible as the first character in a Java identifier.
A character is considered to be a Java letter if and only if
it is a letter or the dollar sign "$" or the underscore "_".
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is a Java letter; false otherwise.
- See Also:
- isLetter, isLetterOrDigit, isJavaLetterOrDigit
isJavaLetterOrDigit
public static boolean isJavaLetterOrDigit(char ch)
- Determines whether the specified character is a "Java" letter or digit,
that is, permissible as a non-initial character in a Java identifier.
A character is considered to be a Java letter or digit if and only if
it is a letter or a digit or the dollar sign "$" or the underscore "_".
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is a Java letter or digit; false otherwise.
- See Also:
- isLetter, isLetterOrDigit, isJavaLetter
toLowerCase
public static char toLowerCase(char ch)
- The given character is mapped to its lowercase equivalent;
if the character has no lowercase equivalent, the character itself is returned.
A character has a lowercase equivalent if and only if a lowercase mapping
is specified for the character in the Unicode 1.1.5 attribute table.
Note that some Unicode characters in the range 0x2000 through 0x2FFF have
lowercase mappings; for example, ` (ROMAN NUMERAL ONE) has a lowercase
mapping to p (SMALL ROMAN NUMERAL ONE). This method does map such
characters to their lowercase equivalents even though the method isUpperCase
does not return true for such characters.
- Parameters:
- ch - the character to be converted
- Returns:
- the lowercase equivalent of the character, if any; otherwise the character itself.
- See Also:
- isLowerCase, isUpperCase, toUpperCase, toTitleCase
toUpperCase
public static char toUpperCase(char ch)
toTitleCase
public static char toTitleCase(char ch)
- The given character is mapped to its titlecase equivalent;
if the character has no titlecase equivalent, the character itself is returned.
A character has a titlecase equivalent if and only if a titlecase mapping
is specified for the character in the Unicode 1.1.5 attribute table.
Note that some Unicode characters in the range 0x2000 through 0x2FFF have
titlecase mappings; for example, p (SMALL ROMAN NUMERAL ONE) has an
titlecase mapping to ` (ROMAN NUMERAL ONE). This method does map such
characters to their titlecase equivalents.
There are only four Unicode characters that are truly titlecase forms
that are distinct from uppercase forms. As a rule, if a character has no
true titlecase equivalent but does have an uppercase mapping, then the
Unicode 1.1.5 attribute table specifies a titlecase mapping that is the
same as the uppercase mapping.
- Parameters:
- ch - the character to be converted
- Returns:
- the titlecase equivalent of the character, if any; otherwise the character itself.
- See Also:
- isTitleCase, toUpperCase, toLowerCase
digit
public static int digit(char ch,
int radix)
- Returns the numeric value of the character digit using the specified
radix. If the radix is not a valid radix, or the character is not a
valid digit in the specified radix, -1 is returned..
A radix is valid if its value is not less than Character.MIN_RADIX
and not greater than Character.MAX_RADIX.
A character is a valid digit iff one of the following is true:
- The method isDigit is true of the character and the Unicode 1.1.5 decimal digit value of the character (or its single-character decomposition) is less than the specified radix.
- The character is an uppercase or lowercase Latin letter and the position of the letter in the Latin alphabet, plus 9, is less than the specified radix.
- Parameters:
- ch - the character to be converted
- radix - the radix
- See Also:
- isDigit, forDigit
isSpace
public static boolean isSpace(char ch)
- Determines if the specified character is ISO-LATIN-1 white space according to Java.
- Parameters:
- ch - the character to be tested
- Returns:
- true if the character is white space; false otherwise.
forDigit
public static char forDigit(int digit,
int radix)
- Returns the character value for the specified digit in the specified
radix. If the digit is not valid in the radix, the 0 character
is returned.
- Parameters:
- digit - the digit chosen by the character value
- radix - the radix containing the digit
charValue
public char charValue()
- Returns the value of this Character object.
hashCode
public int hashCode()
- Returns a hashcode for this Character.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Compares this object against the specified object.
- Parameters:
- obj - the object to compare with
- Returns:
- true if the objects are the same; false otherwise.
- Overrides:
- equals in class Object
toString
public String toString()
- Returns a String object representing this character's value.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index