Package java.lang |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public final class java.lang.Character extends java.lang.Object { // Fields public final static int MAX_RADIX; public final static char MAX_VALUE; public final static int MIN_RADIX; public final static char MIN_VALUE; // Constructors public Character(char value); // Methods public char charValue(); public static int digit(char ch, int radix); public boolean equals(Object obj); public static char forDigit(int digit, int radix); public int hashCode(); public static boolean isDefined(char ch); public static boolean isDigit(char ch); public static boolean isJavaLetter(char ch); public static boolean isJavaLetterOrDigit(char ch); public static boolean isLetter(char ch); public static boolean isLetterOrDigit(char ch); public static boolean isLowerCase(char ch); public static boolean isSpace(char ch); public static boolean isTitleCase(char ch); public static boolean isUpperCase(char ch); public static char toLowerCase(char ch); public String toString(); public static char toTitleCase(char ch); public static char toUpperCase(char ch); }
This class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.
In addition, this class provides a number of methods for determining the type of a character, and converting characters from uppercase to lowercase and vice versa.
Many of the methods of class Character are defined in terms of a "Unicode attribute table" that specifies a name for every defined Unicode code point. The table also includes other attributes, such as a decimal value, an uppercase equivalent, a lowercase equivalent, and/or a titlecase equivalent. The Unicode attribute table is available on the World Wide Web as the file
ftp://unicode.org/pub/MappingTables/UnicodeData1.1.5.txt
public final static int MAX_RADIX = 36The constant value of this field is the largest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.
public final static char MAX_VALUE = '\uffff'The constant value of this field is the largest value of type char.
public final static int MIN_RADIX = 2The constant value of this field is the smallest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.
public final static char MIN_VALUE = '\u0000'The constant value of this field is the smallest value of type char.
public Character(char value)Constructs a Character object and initializes it so that it represents the primitive value argument.
Parameter Description value value for the new Character object
public char charValue()Return Value:
Returns The primitive char value represented by this object.
public static int digit(char ch, int radix)Returns the numeric value of the character ch in the specified radix.
If the radix is not in the range MIN_RADIX £ radix £ MAX_RADIX or if the ch is not a valid digit in the specified radix, -1 is returned. A character is a valid digit if either of the following is true:
- The method isDigit is true of the character and the Unicode decimal digit value of the character (or its single-character decomposition) is less than the specified radix. In this case the decimal digit value is returned.
- The character is one of the uppercase Latin letters 'A' through 'Z' and its code is less that radix + 'A' - 10. In this case, ch - 'A' + 10 is returned.
- The character is one of the lowercase Latin letters 'a' through 'z' and its code is less that radix + 'a' - 10. In this case, ch - 'a' + 10 is returned.
Return Value:
Returns the numeric value represented by the character in the specified radix.
Parameter Description ch the character to be converted radix the radix See Also: forDigit .
public boolean equals(Object obj)The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.
Return Value:
Returns true if the objects are the same; false otherwise.
Parameter Description obj the object to compare with Overrides:
equals in class Object .
public static char forDigit(int digit, int radix)Determines the character representation for a specific digit in the specified radix. If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character ('\u0000') is returned.
The radix argument is valid if it is greater than or equal to MIN_RADIX and less than or equal to MAX_RADIX . The digit argument is valid if 0 £ digit < radix.
If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.
Return Value:
Returns the char representation of the specified digit in the specified radix.
Parameter Description digit the number to convert to a character radix the radix. See Also: digit .
public int hashCode()Return Value:
Returns a hash code value for this object.
Overrides:
hashCode in class Object .
public static boolean isDefined(char ch)Determines if a character has a defined meaning in Unicode. A character is defined if at least one of the following is true:
- It has an entry in the Unicode attribute table.
- Its value is in the range '\u3040' £ ch £ '\u9FA5'
- Its value is in the range '\uF900' £ ch £ '\uFA2D'
Return Value:
Returns true if the character has a defined meaning in Unicode; false otherwise.
Parameter Description ch the character to be tested
public static boolean isDigit(char ch)Determines whether the specified character is a digit. A character is considered to be a digit if it is not in the range '\u2000' through '\uu2000' and its Unicode name contains the word "DIGIT".
Return Value:
Returns true if the character is a digit; false otherwise.
Parameter Description ch the character to be tested
public static boolean isJavaLetter(char ch)Determines whether the specified character is a "Java" letter, that is, the character is permissible as the first character in an identifier in the Java language..
A character is considered to be a Java letter if and only if it is a letter, the ASCII dollar sign character '$', or the underscore character '_'.
Return Value:
Returns true if the character is a Java letter; false otherwise.
Parameter Description ch the character to be tested See Also: isLetter isLetterOrDigit isJavaLetterOrDigit .
public static boolean isJavaLetterOrDigit(char ch)Determines whether the specified character is a "Java" letter or digit, that is, the character is permissible as a non-initial character in an identifier in the Java language..
A character is considered to be a Java letter or digit if and only if it is a letter, a digit, the ASCII dollar sign character '$', or the underscore character '_'.
Return Value:
Returns true if the character is a Java letter or digit; false otherwise.
Parameter Description ch the character to be tested See Also: isLetter isLetterOrDigit isJavaLetter .
public static boolean isLetter(char ch)Determines whether the specified character is a letter.
Return Value:
Returns true if the character is a letter; false otherwise.
Parameter Description ch the character to be tested See Also: isJavaLetter isJavaLetterOrDigit .
public static boolean isLetterOrDigit(char ch)Return Value:
Returns true if the character is a letter or digit; false otherwise.
Parameter Description ch the character to be tested See Also: isDigit isLetter isJavaLetter isJavaLetterOrDigit .
public static boolean isLowerCase(char ch)Determines whether the specified character is a lowercase character.
A character is lowercase if it is not in the range '\u2000' through '\u2FFF', the Unicode attribute table does not specify a mapping to lowercase for the character, and at least one of the following is true:
- the attribute table specifies a mapping to uppercase for the character.
- the name for the character contains the words "SMALL LETTER" .
- the name for the character contains the words "SMALL LIGATURE".
Return Value:
Returns true if the character is lowercase; false otherwise.
Parameter Description ch the character to be tested See Also: isUpperCase isTitleCase toLowerCase .
public static boolean isSpace(char ch)Determines if a character is white space.
This method returns true for the following five characters only:
'\t' \u0009 HORIZONTAL TABULATION '\n' \u000A NEW LINE '\f' \u000C FORM FEED '\r' \u000D CARRIAGE RETURN ' ' \u0020 SPACEReturn Value:
Returns true if the character is ISO-LATIN-1 white space; false otherwise.
Parameter Description ch the character to be tested
public static boolean isTitleCase(char ch)Determines if the character is a titlecase character.
There are four 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". A third form, which looks like "Lj" that is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.
These are the 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
Return Value:
Returns true if the character is titlecase; false otherwise.
Parameter Description ch the character to be tested See Also: isUpperCase isLowerCase toTitleCase .
public static boolean isUpperCase(char ch)Determines whether the specified character is an uppercase character.
A character is uppercase if it is not in the range '\u2000' through '\u2FFF', the Unicode attribute table does not specify a mapping to uppercase for the character, and at least one of the following is true:
- the attribute table specifies a mapping to lowercase for the character.
- the name for the character contains the words "CAPITAL LETTER".
- or the name for the character contains the words "CAPITAL LIGATURE".
Return Value:
Returns true if the character is uppercase; false otherwise.
Parameter Description ch the character to be tested See Also: isLowerCase isTitleCase toUpperCase .
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 attribute table.
Note that some Unicode characters in the range '\u2000' through '\u2FFF' have lowercase mappings; this method does map such characters to their lowercase equivalents even though the method isUpperCase does not return true for such characters.
Return Value:
Returns the lowercase equivalent of the character, if any; otherwise the character itself.
Parameter Description ch the character to be converted See Also: isLowerCase .
public String toString()Converts this Character object to a string. The result is a string whose length is 1 and whose sole component is the primitive char value represented by this object.
Return Value:
Returns a string representation of this object.
Overrides:
toString in class Object .
public static char toTitleCase(char ch)Converts the character argument to titlecase. A character has a titlecase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.
Note that some Unicode characters in the range '\u2000' through '\u2FFF' have titlecase mappings; this method does map such characters to their titlecase equivalents even though the method isTitleCase does not return true for such characters.
Return Value:
Returns the titlecase equivalent of the character, if any; otherwise the character itself.
Parameter Description ch the character to be converted See Also: isTitleCase .
public static char toUpperCase(char ch)Converts the character argument to uppercase. A character has an uppercase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.
Note that some Unicode characters in the range '\u2000' through '\u2000FFF' have uppercase mappings; this method does map such characters to their titlecase equivalents even though the method isLowerCase does not return true for such characters.
Return Value:
Returns the uppercase equivalent of the character, if any; otherwise the character itself.
Parameter Description ch the character to be converted See Also: isUpperCase .
(1)This field is new in Java 1.1.
(2)This field is new in Java 1.1.
(3)This method is new in Java 1.1.
(4)In Version 1.0, this version returns true only for the ten ASCII digits `0' through '9'.
(5)This method is new in Java 1.1
(6)This method is new in Java 1.1
(7)This method is new in Java 1.1
(8)In Version 1.0, this version returns true only for lowercase characters in the range '\u0000' to '\u00FF'.
(9)This method is new in Java 1.1.
(10)In Java 1.0, this method returns true only for uppercase characters in the range '\u0000' to '\u00FF'.
(11)In Java 1.0, this method only works on characters in the range '\u0000' to '\u00FF'. For characters outisde this range, the method returns its argument unchanged.
(12)This method is new in Java 1.1
(13)In Java 1.0, this method only works on characters in the range '\u0000' to '\u00FF'. For characters outside this range, the method returns its argument unchanged.