java.lang
Class 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.


Field Summary
static int MAX_RADIX
          The maximum radix available for conversion to and from Strings.
static char MAX_VALUE
          The maximum value a Character can have.
static int MIN_RADIX
          The minimum radix available for conversion to and from Strings.
static char MIN_VALUE
          The minimum value a Character can have.
 
Constructor Summary
Character(char value)
          Constructs a Character object with the specified value.
 
Method Summary
 char charValue()
          Returns the value of this Character object.
static int digit(char ch, int radix)
          Returns the numeric value of the character digit using the specified radix.
 boolean equals(Object obj)
          Compares this object against the specified object.
static char forDigit(int digit, int radix)
          Returns the character value for the specified digit in the specified radix.
 int hashCode()
          Returns a hashcode for this Character.
static boolean isDefined(char ch)
          Determines whether the specified character actually has a Unicode definition.
static boolean isDigit(char ch)
          Determines whether the specified character is a digit.
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.
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.
static boolean isLetter(char ch)
          Determines whether the specified character is a letter.
static boolean isLetterOrDigit(char ch)
          Determines whether the specified character is a letter or digit.
static boolean isLowerCase(char ch)
          Determines whether the specified character is a lowercase character.
static boolean isSpace(char ch)
          Determines if the specified character is ISO-LATIN-1 white space according to Java.
static boolean isTitleCase(char ch)
          Determines whether the specified character is a titlecase character.
static boolean isUpperCase(char ch)
          Determines whether the specified character is an uppercase character.
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.
 String toString()
          Returns a String object representing this character's value.
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.
static char toUpperCase(char ch)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_RADIX

public static final 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:
Integer.toString(int, int), Constant Field Values

MAX_RADIX

public static final 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:
Integer.toString(int, int), Constant Field Values

MIN_VALUE

public static final char MIN_VALUE
The minimum value a Character can have. The lowest minimum value a Character can have is \u0000.

See Also:
Constant Field Values

MAX_VALUE

public static final char MAX_VALUE
The maximum value a Character can have. The greatest maximum value a Character can have is \uffff.

See Also:
Constant Field Values
Constructor Detail

Character

public Character(char value)
Constructs a Character object with the specified value.

Parameters:
value - value of this Character object
Method Detail

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:

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(char), isTitleCase(char), toLowerCase(char)

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:

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(char), isTitleCase(char), toUpperCase(char)

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 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(char), isLowerCase(char), toTitleCase(char)

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:

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(char, int), forDigit(int, int)

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(char), isLetter(char), isLetterOrDigit(char), isUpperCase(char), isLowerCase(char), isTitleCase(char)

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(char), isLetterOrDigit(char), isJavaLetter(char), isJavaLetterOrDigit(char), isUpperCase(char), isLowerCase(char), isTitleCase(char)

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(char), isLetter(char), isJavaLetter(char), isJavaLetterOrDigit(char)

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(char), isLetterOrDigit(char), isJavaLetterOrDigit(char)

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(char), isLetterOrDigit(char), isJavaLetter(char)

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 ? (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(char), isUpperCase(char), toUpperCase(char), toTitleCase(char)

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, ? (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(char), toUpperCase(char), toLowerCase(char)

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:

Parameters:
ch - the character to be converted
radix - the radix
See Also:
isDigit(char), forDigit(int, int)

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
See Also:
Hashtable

equals

public boolean equals(Object obj)
Compares this object against the specified object.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.
See Also:
Hashtable

toString

public String toString()
Returns a String object representing this character's value.

Overrides:
toString in class Object