Android
java.lang
public final class

java.lang.Character

java.lang.Object
java.lang.Character Serializable Comparable<T>

Character is the wrapper for the primitive type char. This class also provides a number of utility methods for working with chars.

Character data is based upon the Unicode Standard, 4.0. The Unicode specification, character tables and other information are available at http://www.unicode.org/.

Unicode characters are referred to as code points. The range of valid code points is U+0000 to U+10FFFF. The Basic Multilingual Plane (BMP) is the code point range U+0000 to U+FFFF. Characters above the BMP are referred to as Supplementary Characters. On the Java platform, UTF-16 encoding and char pairs are used to represent code points in the supplementary range. A pair of char values that represent a supplementary character are made up of a high surrogate with a value range of 0xD800 to 0xDBFF and a low surrogate with a value range of 0xDC00 to 0xDFFF.

On the Java platform a char value represents either a single BMP code point or a UTF-16 unit that's part of a surrogate pair. The int type is used to represent all Unicode code points.

Nested Classes
Character.Subset  
Character.UnicodeBlock Blocks of characters, as defined by the Unicode 4.0.1 specification. 

Summary

Constants

      Value  
byte  COMBINING_SPACING_MARK  Unicode category constant Mc.  0x00000008 
byte  CONNECTOR_PUNCTUATION  Unicode category constant Pc.  23  0x00000017 
byte  CONTROL  Unicode category constant Cc.  15  0x0000000f 
byte  CURRENCY_SYMBOL  Unicode category constant Sc.  26  0x0000001a 
byte  DASH_PUNCTUATION  Unicode category constant Pd.  20  0x00000014 
byte  DECIMAL_DIGIT_NUMBER  Unicode category constant Nd.  0x00000009 
byte  DIRECTIONALITY_ARABIC_NUMBER  Unicode bidirectional constant AN.  0x00000006 
byte  DIRECTIONALITY_BOUNDARY_NEUTRAL  Unicode bidirectional constant BN.  0x00000009 
byte  DIRECTIONALITY_COMMON_NUMBER_SEPARATOR  Unicode bidirectional constant CS.  0x00000007 
byte  DIRECTIONALITY_EUROPEAN_NUMBER  Unicode bidirectional constant EN.  0x00000003 
byte  DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR  Unicode bidirectional constant ES.  0x00000004 
byte  DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR  Unicode bidirectional constant ET.  0x00000005 
byte  DIRECTIONALITY_LEFT_TO_RIGHT  Unicode bidirectional constant L.  0x00000000 
byte  DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING  Unicode bidirectional constant LRE.  14  0x0000000e 
byte  DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE  Unicode bidirectional constant LRO.  15  0x0000000f 
byte  DIRECTIONALITY_NONSPACING_MARK  Unicode bidirectional constant NSM.  0x00000008 
byte  DIRECTIONALITY_OTHER_NEUTRALS  Unicode bidirectional constant ON.  13  0x0000000d 
byte  DIRECTIONALITY_PARAGRAPH_SEPARATOR  Unicode bidirectional constant B.  10  0x0000000a 
byte  DIRECTIONALITY_POP_DIRECTIONAL_FORMAT  Unicode bidirectional constant PDF.  18  0x00000012 
byte  DIRECTIONALITY_RIGHT_TO_LEFT  Unicode bidirectional constant R.  0x00000001 
byte  DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC  Unicode bidirectional constant AL.  0x00000002 
byte  DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING  Unicode bidirectional constant RLE.  16  0x00000010 
byte  DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE  Unicode bidirectional constant RLO.  17  0x00000011 
byte  DIRECTIONALITY_SEGMENT_SEPARATOR  Unicode bidirectional constant S.  11  0x0000000b 
byte  DIRECTIONALITY_UNDEFINED  Unicode bidirectional constant.  -1  0xffffffff 
byte  DIRECTIONALITY_WHITESPACE  Unicode bidirectional constant WS.  12  0x0000000c 
byte  ENCLOSING_MARK  Unicode category constant Me.  0x00000007 
byte  END_PUNCTUATION  Unicode category constant Pe.  22  0x00000016 
byte  FINAL_QUOTE_PUNCTUATION  Unicode category constant Pf.  30  0x0000001e 
byte  FORMAT  Unicode category constant Cf.  16  0x00000010 
byte  INITIAL_QUOTE_PUNCTUATION  Unicode category constant Pi.  29  0x0000001d 
byte  LETTER_NUMBER  Unicode category constant Nl.  10  0x0000000a 
byte  LINE_SEPARATOR  Unicode category constant Zl.  13  0x0000000d 
byte  LOWERCASE_LETTER  Unicode category constant Ll.  0x00000002 
byte  MATH_SYMBOL  Unicode category constant Sm.  25  0x00000019 
int  MAX_CODE_POINT 

Maximum code point value - U+10FFFF

1114111  0x0010ffff 
char  MAX_HIGH_SURROGATE 

Maximum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '?'

56319  0x0000dbff 
char  MAX_LOW_SURROGATE  Maximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?' 57343  0x0000dfff 
int  MAX_RADIX  The maximum possible radix used for conversions between Characters and integers.  36  0x00000024 
char  MAX_SURROGATE 

Maximum value of a surrogate unit in UTF-16 encoding - '?'

57343  0x0000dfff 
char  MAX_VALUE  The maximum possible Character value.  65535  0x0000ffff 
int  MIN_CODE_POINT 

Minimum code point value - U+0000

0x00000000 
char  MIN_HIGH_SURROGATE 

Minimum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '?'

55296  0x0000d800 
char  MIN_LOW_SURROGATE 

Minimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?'

56320  0x0000dc00 
int  MIN_RADIX  The minimum possible radix used for conversions between Characters and integers.  0x00000002 
int  MIN_SUPPLEMENTARY_CODE_POINT 

Minimum value of a supplementary code point - U+010000

65536  0x00010000 
char  MIN_SURROGATE 

Minimum value of a surrogate unit in UTF-16 encoding - '?'

55296  0x0000d800 
char  MIN_VALUE  The minimum possible Character value.  0x00000000 
byte  MODIFIER_LETTER  Unicode category constant Lm.  0x00000004 
byte  MODIFIER_SYMBOL  Unicode category constant Sk.  27  0x0000001b 
byte  NON_SPACING_MARK  Unicode category constant Mn.  0x00000006 
byte  OTHER_LETTER  Unicode category constant Lo.  0x00000005 
byte  OTHER_NUMBER  Unicode category constant No.  11  0x0000000b 
byte  OTHER_PUNCTUATION  Unicode category constant Po.  24  0x00000018 
byte  OTHER_SYMBOL  Unicode category constant So.  28  0x0000001c 
byte  PARAGRAPH_SEPARATOR  Unicode category constant Zp.  14  0x0000000e 
byte  PRIVATE_USE  Unicode category constant Co.  18  0x00000012 
int  SIZE 

Constant for the number of bits to represent a char in two's compliment form. 

16  0x00000010 
byte  SPACE_SEPARATOR  Unicode category constant Zs.  12  0x0000000c 
byte  START_PUNCTUATION  Unicode category constant Ps.  21  0x00000015 
byte  SURROGATE  Unicode category constant Cs.  19  0x00000013 
byte  TITLECASE_LETTER  Unicode category constant Lt.  0x00000003 
Class<Character TYPE  The char Class object.     
byte  UNASSIGNED  Unicode category constant Cn.  0x00000000 
byte  UPPERCASE_LETTER  Unicode category constant Lu.  0x00000001 

Public Constructors

            Character(char value)
Constructs a new instance of the receiver which represents the char valued argument.

Public Methods

      static    int  charCount(int codePoint)

Calculates the number of char values required to represent the Unicode code point.

          char  charValue()
Returns the char value which the receiver represents.
      static    int  codePointAt(char[] seq, int index)

Returns the code point at the index in the char[].

      static    int  codePointAt(CharSequence seq, int index)

Returns the code point at the index in the CharSequence.

      static    int  codePointAt(char[] seq, int index, int limit)

Returns the code point at the index in the char[] that's within the limit.

      static    int  codePointBefore(CharSequence seq, int index)

Returns the Unicode code point that proceeds the index in the CharSequence.

      static    int  codePointBefore(char[] seq, int index)

Returns the Unicode code point that proceeds the index in the char[].

      static    int  codePointBefore(char[] seq, int index, int start)

Returns the Unicode code point that proceeds the index in the char[] and isn't less than start.

      static    int  codePointCount(CharSequence seq, int beginIndex, int endIndex)

Counts the number of Unicode code points in the subsequence of the CharSequence, as delineated by the beginIndex and endIndex.

      static    int  codePointCount(char[] seq, int offset, int count)

Counts the number of Unicode code points in the subsequence of the char[], as delineated by the offset and count.

          int  compareTo(Character c)
Compares the receiver to the specified Character to determine the relative ordering.
      static    int  digit(int codePoint, int radix)
Convenient method to determine the value of character codePoint in the supplied radix.
      static    int  digit(char c, int radix)
Convenient method to determine the value of character c in the supplied radix.
          boolean  equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
      static    char  forDigit(int digit, int radix)
Returns the character which represents the value in the specified radix.
      static    byte  getDirectionality(int codePoint)
Gets the Unicode directionality of the specified character.
      static    byte  getDirectionality(char c)
Gets the Unicode directionality of the specified character.
      static    int  getNumericValue(int codePoint)
Gets the numeric value of the Unicode character.
      static    int  getNumericValue(char c)
Gets the numeric value of the Unicode character.
      static    int  getType(int codePoint)
Gets the general Unicode category of the specified character.
      static    int  getType(char c)
Gets the general Unicode category of the specified character.
          int  hashCode()
Returns an integer hash code for the receiver.
      static    boolean  isDefined(char c)
Returns whether the specified character is defined in the Unicode specification.
      static    boolean  isDefined(int codePoint)
Returns whether the specified character is defined in the Unicode specification.
      static    boolean  isDigit(int codePoint)
Returns whether the character is a digit.
      static    boolean  isDigit(char c)
Returns whether the character is a digit.
      static    boolean  isHighSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.

      static    boolean  isISOControl(char c)
Returns whether the character is an ISO control character.
      static    boolean  isISOControl(int c)
Returns whether the character is an ISO control character.
      static    boolean  isIdentifierIgnorable(int codePoint)
Returns whether the specified character is ignorable in a Java or Unicode identifier.
      static    boolean  isIdentifierIgnorable(char c)
Returns whether the specified character is ignorable in a Java or Unicode identifier.
      static    boolean  isJavaIdentifierPart(int codePoint)
Returns whether the character is a valid part of a Unicode identifier as other than the first character.
      static    boolean  isJavaIdentifierPart(char c)
Returns whether the character is a valid part of a Unicode identifier as other than the first character.
      static    boolean  isJavaIdentifierStart(char c)
Returns whether the character is a valid start of a Unicode identifier
      static    boolean  isJavaIdentifierStart(int codePoint)
Returns whether the character is a valid start of a Unicode identifier
      static    boolean  isJavaLetter(char c)
This method is deprecated. Use isJavaIdentifierStart(char)
      static    boolean  isJavaLetterOrDigit(char c)
This method is deprecated. Use isJavaIdentifierPart(char)
      static    boolean  isLetter(int codePoint)
Returns whether the character is a letter.
      static    boolean  isLetter(char c)
Returns whether the character is a letter.
      static    boolean  isLetterOrDigit(int codePoint)
Returns whether the character is a letter or a digit.
      static    boolean  isLetterOrDigit(char c)
Returns whether the character is a letter or a digit.
      static    boolean  isLowSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.

      static    boolean  isLowerCase(char c)
Returns whether the character is a lower case letter.
      static    boolean  isLowerCase(int codePoint)
Returns whether the character is a lower case letter.
      static    boolean  isMirrored(char c)
Returns whether the specified character is mirrored
      static    boolean  isMirrored(int codePoint)
Returns whether the specified character is mirrored
      static    boolean  isSpace(char c)
This method is deprecated. Use isWhitespace(char)
      static    boolean  isSpaceChar(char c)
Returns whether the character is a Unicode space character.
      static    boolean  isSpaceChar(int codePoint)
Returns whether the character is a Unicode space character.
      static    boolean  isSupplementaryCodePoint(int codePoint)

A test for determining if the codePoint is within the supplementary code point range.

      static    boolean  isSurrogatePair(char high, char low)

A test for determining if the char pair is a valid surrogate pair.

      static    boolean  isTitleCase(int codePoint)
Returns whether the character is a titlecase character.
      static    boolean  isTitleCase(char c)
Returns whether the character is a titlecase character.
      static    boolean  isUnicodeIdentifierPart(char c)
Returns whether the character is valid as part of a Unicode identifier as other than the first character.
      static    boolean  isUnicodeIdentifierPart(int codePoint)
Returns whether the character is valid as part of a Unicode identifier as other than the first character.
      static    boolean  isUnicodeIdentifierStart(int codePoint)
Returns whether the character is a valid initial character for a Unicode identifier.
      static    boolean  isUnicodeIdentifierStart(char c)
Returns whether the character is a valid initial character for a Unicode identifier.
      static    boolean  isUpperCase(char c)
Returns whether the character is an upper case letter.
      static    boolean  isUpperCase(int codePoint)
Returns whether the character is an upper case letter.
      static    boolean  isValidCodePoint(int codePoint)

A test for determining if the codePoint is a valid Unicode code point.

      static    boolean  isWhitespace(int codePoint)
Returns whether the character is a whitespace character in Java.
      static    boolean  isWhitespace(char c)
Returns whether the character is a whitespace character in Java.
      static    int  offsetByCodePoints(char[] seq, int start, int count, int index, int codePointOffset)

Determines the index into the char[] that is offset (measured in code points and specified by codePointOffset), from the index argument and is within the subsequence as delineated by start and count.

      static    int  offsetByCodePoints(CharSequence seq, int index, int codePointOffset)

Determines the index into the CharSequence that is offset (measured in code points and specified by codePointOffset), from the index argument.

      static    char  reverseBytes(char c)
Reverse the order of the first and second bytes in character
      static    char[]  toChars(int codePoint)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence that is returned as a char[].

      static    int  toChars(int codePoint, char[] dst, int dstIndex)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence and copies the value(s) into the char[] dst, starting at the index dstIndex.

      static    int  toCodePoint(char high, char low)

Converts a surrogate pair into a Unicode code point.

      static    int  toLowerCase(int codePoint)
Returns the lower case equivalent for the character when the character is an upper case letter, otherwise returns the character.
      static    char  toLowerCase(char c)
Returns the lower case equivalent for the character when the character is an upper case letter, otherwise returns the character.
      static    String  toString(char value)
Converts the specified character to its string representation.
          String  toString()
Returns a string containing a concise, human-readable description of the receiver.
      static    int  toTitleCase(int codePoint)
Returns the title case equivalent for the character, otherwise returns the character.
      static    char  toTitleCase(char c)
Returns the title case equivalent for the character, otherwise returns the character.
      static    char  toUpperCase(char c)
Returns the upper case equivalent for the character when the character is a lower case letter, otherwise returns the character.
      static    int  toUpperCase(int codePoint)
Returns the upper case equivalent for the character when the character is a lower case letter, otherwise returns the character.
      static    Character  valueOf(char c)

Returns a Character instance for the char value passed.

Methods inherited from class java.lang.Object
Methods inherited from interface java.lang.Comparable

Details

Constants

public static final byte COMBINING_SPACING_MARK

Unicode category constant Mc.
Constant Value: 8 (0x00000008)

public static final byte CONNECTOR_PUNCTUATION

Unicode category constant Pc.
Constant Value: 23 (0x00000017)

public static final byte CONTROL

Unicode category constant Cc.
Constant Value: 15 (0x0000000f)

public static final byte CURRENCY_SYMBOL

Unicode category constant Sc.
Constant Value: 26 (0x0000001a)

public static final byte DASH_PUNCTUATION

Unicode category constant Pd.
Constant Value: 20 (0x00000014)

public static final byte DECIMAL_DIGIT_NUMBER

Unicode category constant Nd.
Constant Value: 9 (0x00000009)

public static final byte DIRECTIONALITY_ARABIC_NUMBER

Unicode bidirectional constant AN.
Constant Value: 6 (0x00000006)

public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL

Unicode bidirectional constant BN.
Constant Value: 9 (0x00000009)

public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

Unicode bidirectional constant CS.
Constant Value: 7 (0x00000007)

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER

Unicode bidirectional constant EN.
Constant Value: 3 (0x00000003)

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

Unicode bidirectional constant ES.
Constant Value: 4 (0x00000004)

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

Unicode bidirectional constant ET.
Constant Value: 5 (0x00000005)

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT

Unicode bidirectional constant L.
Constant Value: 0 (0x00000000)

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

Unicode bidirectional constant LRE.
Constant Value: 14 (0x0000000e)

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

Unicode bidirectional constant LRO.
Constant Value: 15 (0x0000000f)

public static final byte DIRECTIONALITY_NONSPACING_MARK

Unicode bidirectional constant NSM.
Constant Value: 8 (0x00000008)

public static final byte DIRECTIONALITY_OTHER_NEUTRALS

Unicode bidirectional constant ON.
Constant Value: 13 (0x0000000d)

public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR

Unicode bidirectional constant B.
Constant Value: 10 (0x0000000a)

public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

Unicode bidirectional constant PDF.
Constant Value: 18 (0x00000012)

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT

Unicode bidirectional constant R.
Constant Value: 1 (0x00000001)

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

Unicode bidirectional constant AL.
Constant Value: 2 (0x00000002)

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

Unicode bidirectional constant RLE.
Constant Value: 16 (0x00000010)

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

Unicode bidirectional constant RLO.
Constant Value: 17 (0x00000011)

public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR

Unicode bidirectional constant S.
Constant Value: 11 (0x0000000b)

public static final byte DIRECTIONALITY_UNDEFINED

Unicode bidirectional constant.
Constant Value: -1 (0xffffffff)

public static final byte DIRECTIONALITY_WHITESPACE

Unicode bidirectional constant WS.
Constant Value: 12 (0x0000000c)

public static final byte ENCLOSING_MARK

Unicode category constant Me.
Constant Value: 7 (0x00000007)

public static final byte END_PUNCTUATION

Unicode category constant Pe.
Constant Value: 22 (0x00000016)

public static final byte FINAL_QUOTE_PUNCTUATION

Unicode category constant Pf.
Constant Value: 30 (0x0000001e)

public static final byte FORMAT

Unicode category constant Cf.
Constant Value: 16 (0x00000010)

public static final byte INITIAL_QUOTE_PUNCTUATION

Unicode category constant Pi.
Constant Value: 29 (0x0000001d)

public static final byte LETTER_NUMBER

Unicode category constant Nl.
Constant Value: 10 (0x0000000a)

public static final byte LINE_SEPARATOR

Unicode category constant Zl.
Constant Value: 13 (0x0000000d)

public static final byte LOWERCASE_LETTER

Unicode category constant Ll.
Constant Value: 2 (0x00000002)

public static final byte MATH_SYMBOL

Unicode category constant Sm.
Constant Value: 25 (0x00000019)

public static final int MAX_CODE_POINT

Maximum code point value - U+10FFFF.

Constant Value: 1114111 (0x0010ffff)

public static final char MAX_HIGH_SURROGATE

Maximum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '?'.

Constant Value: 56319 (0x0000dbff)

public static final char MAX_LOW_SURROGATE

Maximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?'.

Constant Value: 57343 (0x0000dfff)

public static final int MAX_RADIX

The maximum possible radix used for conversions between Characters and integers.
Constant Value: 36 (0x00000024)

public static final char MAX_SURROGATE

Maximum value of a surrogate unit in UTF-16 encoding - '?'.

Constant Value: 57343 (0x0000dfff)

public static final char MAX_VALUE

The maximum possible Character value.
Constant Value: 65535 (0x0000ffff)

public static final int MIN_CODE_POINT

Minimum code point value - U+0000.

Constant Value: 0 (0x00000000)

public static final char MIN_HIGH_SURROGATE

Minimum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '?'.

Constant Value: 55296 (0x0000d800)

public static final char MIN_LOW_SURROGATE

Minimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?'.

Constant Value: 56320 (0x0000dc00)

public static final int MIN_RADIX

The minimum possible radix used for conversions between Characters and integers.
Constant Value: 2 (0x00000002)

public static final int MIN_SUPPLEMENTARY_CODE_POINT

Minimum value of a supplementary code point - U+010000.

Constant Value: 65536 (0x00010000)

public static final char MIN_SURROGATE

Minimum value of a surrogate unit in UTF-16 encoding - '?'.

Constant Value: 55296 (0x0000d800)

public static final char MIN_VALUE

The minimum possible Character value.
Constant Value: 0 (0x00000000)

public static final byte MODIFIER_LETTER

Unicode category constant Lm.
Constant Value: 4 (0x00000004)

public static final byte MODIFIER_SYMBOL

Unicode category constant Sk.
Constant Value: 27 (0x0000001b)

public static final byte NON_SPACING_MARK

Unicode category constant Mn.
Constant Value: 6 (0x00000006)

public static final byte OTHER_LETTER

Unicode category constant Lo.
Constant Value: 5 (0x00000005)

public static final byte OTHER_NUMBER

Unicode category constant No.
Constant Value: 11 (0x0000000b)

public static final byte OTHER_PUNCTUATION

Unicode category constant Po.
Constant Value: 24 (0x00000018)

public static final byte OTHER_SYMBOL

Unicode category constant So.
Constant Value: 28 (0x0000001c)

public static final byte PARAGRAPH_SEPARATOR

Unicode category constant Zp.
Constant Value: 14 (0x0000000e)

public static final byte PRIVATE_USE

Unicode category constant Co.
Constant Value: 18 (0x00000012)

public static final int SIZE

Constant for the number of bits to represent a char in two's compliment form.

Constant Value: 16 (0x00000010)

public static final byte SPACE_SEPARATOR

Unicode category constant Zs.
Constant Value: 12 (0x0000000c)

public static final byte START_PUNCTUATION

Unicode category constant Ps.
Constant Value: 21 (0x00000015)

public static final byte SURROGATE

Unicode category constant Cs.
Constant Value: 19 (0x00000013)

public static final byte TITLECASE_LETTER

Unicode category constant Lt.
Constant Value: 3 (0x00000003)

public static final Class<Character> TYPE

The char Class object.

public static final byte UNASSIGNED

Unicode category constant Cn.
Constant Value: 0 (0x00000000)

public static final byte UPPERCASE_LETTER

Unicode category constant Lu.
Constant Value: 1 (0x00000001)

Public Constructors

public Character(char value)

Constructs a new instance of the receiver which represents the char valued argument.

Parameters

value the char to store in the new instance.

Public Methods

public static int charCount(int codePoint)

Calculates the number of char values required to represent the Unicode code point. This method only tests if the codePoint is greater than or equal to 0x10000, in which case 2 is returned, otherwise 1. To test if the code point is valid, use the isValidCodePoint(int) method.

Parameters

codePoint The code point to test.

Returns

  • An int value of 2 or 1.

public char charValue()

Returns the char value which the receiver represents.

Returns

  • char the value of the receiver

public static int codePointAt(char[] seq, int index)

Returns the code point at the index in the char[]. If char unit at the index is a high-surrogate unit, the next index is less than the length of the sequence and the char unit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise the char unit at the index is returned.

Parameters

seq The sequence of char units.
index The index into the seq to retrieve and convert.

Returns

  • The Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if the index is negative or greater than or equal to seq.length().

public static int codePointAt(CharSequence seq, int index)

Returns the code point at the index in the CharSequence. If char unit at the index is a high-surrogate unit, the next index is less than the length of the sequence and the char unit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise the char unit at the index is returned.

Parameters

seq The sequence of char units.
index The index into the seq to retrieve and convert.

Returns

  • The Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if the index is negative or greater than or equal to seq.length().

public static int codePointAt(char[] seq, int index, int limit)

Returns the code point at the index in the char[] that's within the limit. If char unit at the index is a high-surrogate unit, the next index is less than the limit and the char unit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise the char unit at the index is returned.

Parameters

seq The sequence of char units.
index The index into the seq to retrieve and convert.
limit The exclusive index into the seq that marks the end of the units that can be used.

Returns

  • The Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if the index is negative, greater than or equal to limit, limit is negative or limit is greater than the length of seq.

public static int codePointBefore(CharSequence seq, int index)

Returns the Unicode code point that proceeds the index in the CharSequence. If the char unit at index - 1 is within the low surrogate range, the value index - 2 isn't negative and the char unit at index - 2 is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, the char value at index - 1 is returned.

Parameters

seq The CharSequence to search.
index The index into the seq.

Returns

  • A Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if index is less than 1 or greater than seq.length().

public static int codePointBefore(char[] seq, int index)

Returns the Unicode code point that proceeds the index in the char[]. If the char unit at index - 1 is within the low surrogate range, the value index - 2 isn't negative and the char unit at index - 2 is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, the char value at index - 1 is returned.

Parameters

seq The char[] to search.
index The index into the seq.

Returns

  • A Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if index is less than 1 or greater than seq.length.

public static int codePointBefore(char[] seq, int index, int start)

Returns the Unicode code point that proceeds the index in the char[] and isn't less than start. If the char unit at index - 1 is within the low surrogate range, the value index - 2 isn't less than start and the char unit at index - 2 is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, the char value at index - 1 is returned.

Parameters

seq The char[] to search.
index The index into the seq.

Returns

  • A Unicode code point.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if index is less than or equal to start, index is greater than seq.length, start is not negative and start is greater than seq.length.

public static int codePointCount(CharSequence seq, int beginIndex, int endIndex)

Counts the number of Unicode code points in the subsequence of the CharSequence, as delineated by the beginIndex and endIndex. Any surrogate values with missing pair values will be counted as 1 code point.

Parameters

seq The CharSequence to look through.
beginIndex The inclusive index to begin counting at.
endIndex The exclusive index to stop counting at.

Returns

  • The number of Unicode code points.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if beginIndex is negative, greater than seq.length() or greater than endIndex.

public static int codePointCount(char[] seq, int offset, int count)

Counts the number of Unicode code points in the subsequence of the char[], as delineated by the offset and count. Any surrogate values with missing pair values will be counted as 1 code point.

Parameters

seq The char[] to look through.
offset The inclusive index to begin counting at.
count The number of char values to look through in seq.

Returns

  • The number of Unicode code points.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if offset or count is negative or if endIndex is greater than seq.length.

public int compareTo(Character c)

Compares the receiver to the specified Character to determine the relative ordering.

Parameters

c the Character

Returns

  • an int < 0 if this Character is less than the specified Character, 0 if they are equal, and > 0 if this Character is greater

Throws

NullPointerException if c is null.

public static int digit(int codePoint, int radix)

Convenient method to determine the value of character codePoint in the supplied radix. The value of radix must be between MIN_RADIX and MAX_RADIX.

Parameters

codePoint the character, including supplementary characters
radix the radix

Returns

  • if radix lies between MIN_RADIX and MAX_RADIX then the value of the character in the radix, otherwise -1.

public static int digit(char c, int radix)

Convenient method to determine the value of character c in the supplied radix. The value of radix must be between MIN_RADIX and MAX_RADIX.

Parameters

c the character
radix the radix

Returns

  • if radix lies between MIN_RADIX and MAX_RADIX then the value of the character in the radix, otherwise -1.

public boolean equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

In this case, the argument must also be a Character, and the receiver and argument must represent the same char value.

Parameters

object the object to compare with this object

Returns

  • true if the object is the same as this object false if it is different from this object

See Also

public static char forDigit(int digit, int radix)

Returns the character which represents the value in the specified radix. The radix must be between MIN_RADIX and MAX_RADIX inclusive.

Parameters

digit the integer value
radix the radix

Returns

  • the character which represents the value in the radix

public static byte getDirectionality(int codePoint)

Gets the Unicode directionality of the specified character.

Parameters

codePoint the character, including supplementary characters

Returns

  • the Unicode directionality

public static byte getDirectionality(char c)

Gets the Unicode directionality of the specified character.

Parameters

c the character

Returns

  • the Unicode directionality

public static int getNumericValue(int codePoint)

Gets the numeric value of the Unicode character.

Parameters

codePoint the character, including supplementary characters

Returns

  • a numeric int value which is not negative, -1 if there is no numeric value, -2 if the numeric value is negative

public static int getNumericValue(char c)

Gets the numeric value of the Unicode character.

Parameters

c the character

Returns

  • a numeric int value >= 0, -1 if there is no numeric value, -2 if the numeric value is not an int >= 0

public static int getType(int codePoint)

Gets the general Unicode category of the specified character.

Parameters

codePoint the character, including supplementary characters

Returns

  • the Unicode category

public static int getType(char c)

Gets the general Unicode category of the specified character.

Parameters

c the character

Returns

  • the Unicode category

public int hashCode()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Returns

  • the receiver's hash

See Also

public static boolean isDefined(char c)

Returns whether the specified character is defined in the Unicode specification.

Parameters

c the character

Returns

  • true if the general Unicode category of the character is not UNASSIGNED, false otherwise

public static boolean isDefined(int codePoint)

Returns whether the specified character is defined in the Unicode specification.

Parameters

codePoint the character, including supplementary characters

Returns

  • true if the general Unicode category of the character is not UNASSIGNED, false otherwise

public static boolean isDigit(int codePoint)

Returns whether the character is a digit.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a digit, false otherwise

public static boolean isDigit(char c)

Returns whether the character is a digit.

Parameters

c the character

Returns

  • true when the character is a digit, false otherwise

public static boolean isHighSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.

Parameters

ch The char unit to test.

Returns

  • A boolean value.

public static boolean isISOControl(char c)

Returns whether the character is an ISO control character.

Parameters

c the character

Returns

  • true if c is an ISO control character, otherwise false

public static boolean isISOControl(int c)

Returns whether the character is an ISO control character.

Parameters

c the character, including supplementary characters

Returns

  • true if c is an ISO control character, otherwise false

public static boolean isIdentifierIgnorable(int codePoint)

Returns whether the specified character is ignorable in a Java or Unicode identifier.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is ignorable, false otherwise

public static boolean isIdentifierIgnorable(char c)

Returns whether the specified character is ignorable in a Java or Unicode identifier.

Parameters

c the character

Returns

  • true when the character is ignorable, false otherwise

public static boolean isJavaIdentifierPart(int codePoint)

Returns whether the character is a valid part of a Unicode identifier as other than the first character.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is valid as part of a Java identifier, false otherwise

public static boolean isJavaIdentifierPart(char c)

Returns whether the character is a valid part of a Unicode identifier as other than the first character.

Parameters

c the character

Returns

  • true when the character is valid as part of a Java identifier, false otherwise

public static boolean isJavaIdentifierStart(char c)

Returns whether the character is a valid start of a Unicode identifier

Parameters

c the character

Returns

  • true when the character is a valid start of a Java identifier, false otherwise

public static boolean isJavaIdentifierStart(int codePoint)

Returns whether the character is a valid start of a Unicode identifier

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a valid start of a Java identifier, false otherwise

public static boolean isJavaLetter(char c)

This method is deprecated. Use isJavaIdentifierStart(char)

Returns whether the character is a Java letter.

public static boolean isJavaLetterOrDigit(char c)

This method is deprecated. Use isJavaIdentifierPart(char)

Returns whether the character is a Java letter or digit character.

public static boolean isLetter(int codePoint)

Returns whether the character is a letter.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a letter, false otherwise

public static boolean isLetter(char c)

Returns whether the character is a letter.

Parameters

c the character

Returns

  • true when the character is a letter, false otherwise

public static boolean isLetterOrDigit(int codePoint)

Returns whether the character is a letter or a digit.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a letter or a digit, false otherwise

public static boolean isLetterOrDigit(char c)

Returns whether the character is a letter or a digit.

Parameters

c the character

Returns

  • true when the character is a letter or a digit, false otherwise

public static boolean isLowSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.

Parameters

ch The char unit to test.

Returns

  • A boolean value.

public static boolean isLowerCase(char c)

Returns whether the character is a lower case letter.

Parameters

c the character

Returns

  • true when the character is a lower case letter, false otherwise

public static boolean isLowerCase(int codePoint)

Returns whether the character is a lower case letter.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a lower case letter, false otherwise

public static boolean isMirrored(char c)

Returns whether the specified character is mirrored

Parameters

c the character

Returns

  • true if the character is mirrored, false otherwise

public static boolean isMirrored(int codePoint)

Returns whether the specified character is mirrored

Parameters

codePoint the character, including supplementary characters

Returns

  • true if the character is mirrored, false otherwise

public static boolean isSpace(char c)

This method is deprecated. Use isWhitespace(char)

Returns whether the character is a Java space.

public static boolean isSpaceChar(char c)

Returns whether the character is a Unicode space character. A member of one of the Unicode categories Space Separator, Line Separator, or Paragraph Separator.

Parameters

c the character

Returns

  • true when the character is a Unicode space character, false otherwise

public static boolean isSpaceChar(int codePoint)

Returns whether the character is a Unicode space character. A member of one of the Unicode categories Space Separator, Line Separator, or Paragraph Separator.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a Unicode space character, false otherwise

public static boolean isSupplementaryCodePoint(int codePoint)

A test for determining if the codePoint is within the supplementary code point range.

Parameters

codePoint The code point to test.

Returns

  • A boolean value.

public static boolean isSurrogatePair(char high, char low)

A test for determining if the char pair is a valid surrogate pair.

Parameters

high The high surrogate unit to test.
low The low surrogate unit to test.

Returns

  • A boolean value.

public static boolean isTitleCase(int codePoint)

Returns whether the character is a titlecase character.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a titlecase character, false otherwise

public static boolean isTitleCase(char c)

Returns whether the character is a titlecase character.

Parameters

c the character

Returns

  • true when the character is a titlecase character, false otherwise

public static boolean isUnicodeIdentifierPart(char c)

Returns whether the character is valid as part of a Unicode identifier as other than the first character.

Parameters

c the character

Returns

  • true when the character is valid as part of a Unicode identifier, false otherwise

public static boolean isUnicodeIdentifierPart(int codePoint)

Returns whether the character is valid as part of a Unicode identifier as other than the first character.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is valid as part of a Unicode identifier, false otherwise

public static boolean isUnicodeIdentifierStart(int codePoint)

Returns whether the character is a valid initial character for a Unicode identifier.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a valid start of a Unicode identifier, false otherwise

public static boolean isUnicodeIdentifierStart(char c)

Returns whether the character is a valid initial character for a Unicode identifier.

Parameters

c the character

Returns

  • true when the character is a valid start of a Unicode identifier, false otherwise

public static boolean isUpperCase(char c)

Returns whether the character is an upper case letter.

Parameters

c the character

Returns

  • true when the character is a upper case letter, false otherwise

public static boolean isUpperCase(int codePoint)

Returns whether the character is an upper case letter.

Parameters

codePoint the character, including supplementary characters

Returns

  • true when the character is a upper case letter, false otherwise

public static boolean isValidCodePoint(int codePoint)

A test for determining if the codePoint is a valid Unicode code point.

Parameters

codePoint The code point to test.

Returns

  • A boolean value.

public static boolean isWhitespace(int codePoint)

Returns whether the character is a whitespace character in Java.

Parameters

codePoint the character, including supplementary characters

Returns

  • true if the supplied c is a whitespace character in Java, otherwise false.

public static boolean isWhitespace(char c)

Returns whether the character is a whitespace character in Java.

Parameters

c the character

Returns

  • true if the supplied c is a whitespace character in Java, otherwise false.

public static int offsetByCodePoints(char[] seq, int start, int count, int index, int codePointOffset)

Determines the index into the char[] that is offset (measured in code points and specified by codePointOffset), from the index argument and is within the subsequence as delineated by start and count.

Parameters

seq The char[] to find the index within.
start The inclusive index that marks the beginning of the subsequence.
count The number of char values to include within the subsequence.
index The index to begin from, within the char[].
codePointOffset The number of code points to look back or forwards; may be a negative or positive value.

Returns

  • The calculated index that is codePointOffset code points from index.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if start or count is negative, start + count greater than seq.length, index is less than start, index is greater than start + count or there aren't enough values in seq after index or before index if codePointOffset is negative.

public static int offsetByCodePoints(CharSequence seq, int index, int codePointOffset)

Determines the index into the CharSequence that is offset (measured in code points and specified by codePointOffset), from the index argument.

Parameters

seq The CharSequence to find the index within.
index The index to begin from, within the CharSequence.
codePointOffset The number of code points to look back or forwards; may be a negative or positive value.

Returns

  • The calculated index that is codePointOffset code points from index.

Throws

NullPointerException if seq is null.
IndexOutOfBoundsException if index is negative, greater than seq.length(), there aren't enough values in seq after index or before index if codePointOffset is negative.

public static char reverseBytes(char c)

Reverse the order of the first and second bytes in character

Parameters

c the character

Returns

  • the character with reordered bytes.

public static char[] toChars(int codePoint)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence that is returned as a char[].

Parameters

codePoint The Unicode code point to encode.

Returns

  • The UTF-16 encoded char sequence; if code point is a supplementary code point, then a 2 char array is returned, otherwise a 1 char array is returned.

Throws

IllegalArgumentException if codePoint is not a valid Unicode code point.

public static int toChars(int codePoint, char[] dst, int dstIndex)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence and copies the value(s) into the char[] dst, starting at the index dstIndex.

Parameters

codePoint The Unicode code point to encode.
dst The char[] to copy the encoded value into.
dstIndex The index to start copying into dst.

Returns

  • The number of char value units copied into dst.

Throws

IllegalArgumentException if codePoint is not a valid Unicode code point.
NullPointerException if dst is null.
IndexOutOfBoundsException if dstIndex is negative, greater than or equal to dst.length or equals dst.length - 1 when codePoint is a supplementary code point.

public static int toCodePoint(char high, char low)

Converts a surrogate pair into a Unicode code point. This method assume that the pair are valid surrogates. If the pair are NOT valid surrogates, then the result is indeterminate. The isSurrogatePair(char, char) method should be used prior to this method to validate the pair.

Parameters

high The high surrogate unit.
low The low surrogate unit.

Returns

  • The decoded code point.

public static int toLowerCase(int codePoint)

Returns the lower case equivalent for the character when the character is an upper case letter, otherwise returns the character.

Parameters

codePoint the character, including supplementary characters

Returns

  • if codePoint is not a lower case character then its lower case counterpart, otherwise just codePoint

public static char toLowerCase(char c)

Returns the lower case equivalent for the character when the character is an upper case letter, otherwise returns the character.

Parameters

c the character

Returns

  • if c is not a lower case character then its lower case counterpart, otherwise just c

public static String toString(char value)

Converts the specified character to its string representation.

Parameters

value the character

Returns

  • the character converted to a string

public String toString()

Returns a string containing a concise, human-readable description of the receiver.

Returns

  • a printable representation for the receiver.

public static int toTitleCase(int codePoint)

Returns the title case equivalent for the character, otherwise returns the character.

Parameters

codePoint the character

Returns

  • the title case equivalent of the character

public static char toTitleCase(char c)

Returns the title case equivalent for the character, otherwise returns the character.

Parameters

c the character

Returns

  • the title case equivalent of the character

public static char toUpperCase(char c)

Returns the upper case equivalent for the character when the character is a lower case letter, otherwise returns the character.

Parameters

c the character

Returns

  • if c is not an upper case character then its upper case counterpart, otherwise just c

public static int toUpperCase(int codePoint)

Returns the upper case equivalent for the character when the character is a lower case letter, otherwise returns the character.

Parameters

codePoint the character, including supplementary characters

Returns

  • if codePoint is not an upper case character then its upper case counterpart, otherwise just codePoint

public static Character valueOf(char c)

Returns a Character instance for the char value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.

Parameters

c The char value.

Returns

  • A Character instance.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56