Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Character

public final class Character
extends Object implements Serializable, Comparable<Character>

java.lang.Object
   ↳ java.lang.Character


The wrapper for the primitive type char. This class also provides a number of utility methods for working with characters.

Character data is kept up to date as Unicode evolves. See the Locale data section of the Locale documentation for details of the Unicode versions implemented by current and historical Android releases.

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.

Unicode categories

Here's a list of the Unicode character categories and the corresponding Java constant, grouped semantically to provide a convenient overview. This table is also useful in conjunction with \p and \P in regular expressions.

Cn Unassigned UNASSIGNED
Cc Control CONTROL
Cf Format FORMAT
Co Private use PRIVATE_USE
Cs Surrogate SURROGATE

Lu Uppercase letter UPPERCASE_LETTER
Ll Lowercase letter LOWERCASE_LETTER
Lt Titlecase letter TITLECASE_LETTER
Lm Modifier letter MODIFIER_LETTER
Lo Other letter OTHER_LETTER

Mn Non-spacing mark NON_SPACING_MARK
Me Enclosing mark ENCLOSING_MARK
Mc Combining spacing mark COMBINING_SPACING_MARK

Nd Decimal digit number DECIMAL_DIGIT_NUMBER
Nl Letter number LETTER_NUMBER
No Other number OTHER_NUMBER

Pd Dash punctuation DASH_PUNCTUATION
Ps Start punctuation START_PUNCTUATION
Pe End punctuation END_PUNCTUATION
Pc Connector punctuation CONNECTOR_PUNCTUATION
Pi Initial quote punctuation INITIAL_QUOTE_PUNCTUATION
Pf Final quote punctuation FINAL_QUOTE_PUNCTUATION
Po Other punctuation OTHER_PUNCTUATION

Sm Math symbol MATH_SYMBOL
Sc Currency symbol CURRENCY_SYMBOL
Sk Modifier symbol MODIFIER_SYMBOL
So Other symbol OTHER_SYMBOL

Zs Space separator SPACE_SEPARATOR
Zl Line separator LINE_SEPARATOR
Zp Paragraph separator PARAGRAPH_SEPARATOR

Summary

Nested classes

class Character.Subset

 

class Character.UnicodeBlock

Represents a block of Unicode characters. 

Constants

byte COMBINING_SPACING_MARK

Unicode category constant Mc.

byte CONNECTOR_PUNCTUATION

Unicode category constant Pc.

byte CONTROL

Unicode category constant Cc.

byte CURRENCY_SYMBOL

Unicode category constant Sc.

byte DASH_PUNCTUATION

Unicode category constant Pd.

byte DECIMAL_DIGIT_NUMBER

Unicode category constant Nd.

byte DIRECTIONALITY_ARABIC_NUMBER

Unicode bidirectional constant AN.

byte DIRECTIONALITY_BOUNDARY_NEUTRAL

Unicode bidirectional constant BN.

byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

Unicode bidirectional constant CS.

byte DIRECTIONALITY_EUROPEAN_NUMBER

Unicode bidirectional constant EN.

byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

Unicode bidirectional constant ES.

byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

Unicode bidirectional constant ET.

byte DIRECTIONALITY_LEFT_TO_RIGHT

Unicode bidirectional constant L.

byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

Unicode bidirectional constant LRE.

byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

Unicode bidirectional constant LRO.

byte DIRECTIONALITY_NONSPACING_MARK

Unicode bidirectional constant NSM.

byte DIRECTIONALITY_OTHER_NEUTRALS

Unicode bidirectional constant ON.

byte DIRECTIONALITY_PARAGRAPH_SEPARATOR

Unicode bidirectional constant B.

byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

Unicode bidirectional constant PDF.

byte DIRECTIONALITY_RIGHT_TO_LEFT

Unicode bidirectional constant R.

byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

Unicode bidirectional constant AL.

byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

Unicode bidirectional constant RLE.

byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

Unicode bidirectional constant RLO.

byte DIRECTIONALITY_SEGMENT_SEPARATOR

Unicode bidirectional constant S.

byte DIRECTIONALITY_UNDEFINED

Unicode bidirectional constant.

byte DIRECTIONALITY_WHITESPACE

Unicode bidirectional constant WS.

byte ENCLOSING_MARK

Unicode category constant Me.

byte END_PUNCTUATION

Unicode category constant Pe.

byte FINAL_QUOTE_PUNCTUATION

Unicode category constant Pf.

byte FORMAT

Unicode category constant Cf.

byte INITIAL_QUOTE_PUNCTUATION

Unicode category constant Pi.

byte LETTER_NUMBER

Unicode category constant Nl.

byte LINE_SEPARATOR

Unicode category constant Zl.

byte LOWERCASE_LETTER

Unicode category constant Ll.

byte MATH_SYMBOL

Unicode category constant Sm.

int MAX_CODE_POINT

The maximum code point value, U+10FFFF.

char MAX_HIGH_SURROGATE

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

char MAX_LOW_SURROGATE

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

int MAX_RADIX

The maximum radix used for conversions between characters and integers.

char MAX_SURROGATE

The maximum value of a surrogate unit in UTF-16 encoding, '?'.

char MAX_VALUE

The maximum Character value.

int MIN_CODE_POINT

The minimum code point value, U+0000.

char MIN_HIGH_SURROGATE

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

char MIN_LOW_SURROGATE

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

int MIN_RADIX

The minimum radix used for conversions between characters and integers.

int MIN_SUPPLEMENTARY_CODE_POINT

The minimum value of a supplementary code point, U+010000.

char MIN_SURROGATE

The minimum value of a surrogate unit in UTF-16 encoding, '?'.

char MIN_VALUE

The minimum Character value.

byte MODIFIER_LETTER

Unicode category constant Lm.

byte MODIFIER_SYMBOL

Unicode category constant Sk.

byte NON_SPACING_MARK

Unicode category constant Mn.

byte OTHER_LETTER

Unicode category constant Lo.

byte OTHER_NUMBER

Unicode category constant No.

byte OTHER_PUNCTUATION

Unicode category constant Po.

byte OTHER_SYMBOL

Unicode category constant So.

byte PARAGRAPH_SEPARATOR

Unicode category constant Zp.

byte PRIVATE_USE

Unicode category constant Co.

int SIZE

The number of bits required to represent a Character value unsigned form.

byte SPACE_SEPARATOR

Unicode category constant Zs.

byte START_PUNCTUATION

Unicode category constant Ps.

byte SURROGATE

Unicode category constant Cs.

byte TITLECASE_LETTER

Unicode category constant Lt.

byte UNASSIGNED

Unicode category constant Cn.

byte UPPERCASE_LETTER

Unicode category constant Lu.

Fields

public static final Class<Character> TYPE

The Class object that represents the primitive type char.

Public constructors

Character(char value)

Constructs a new Character with the specified primitive char value.

Public methods

static int charCount(int codePoint)

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

char charValue()

Gets the primitive value of this character.

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

Returns the code point at index in the specified array of character units.

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

Returns the code point at index in the specified array of character units, where index has to be less than limit.

static int codePointAt(CharSequence seq, int index)

Returns the code point at index in the specified sequence of character units.

static int codePointBefore(CharSequence seq, int index)

Returns the code point that precedes index in the specified sequence of character units.

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

Returns the code point that precedes the index in the specified array of character units and is not less than start.

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

Returns the code point that precedes index in the specified array of character units.

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

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

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

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

static int compare(char lhs, char rhs)

Compares two char values.

int compareTo(Character c)

Compares this object to the specified character object to determine their relative order.

static int digit(char c, int radix)

Convenience method to determine the value of the specified character c in the supplied radix.

static int digit(int codePoint, int radix)

Convenience method to determine the value of the character codePoint in the supplied radix.

boolean equals(Object object)

Compares this object with the specified object and indicates if they are equal.

static char forDigit(int digit, int radix)

Returns the character which represents the specified digit in the specified radix.

static byte getDirectionality(int codePoint)

Returns the Unicode directionality of the given code point.

static byte getDirectionality(char c)

Gets the Unicode directionality of the specified character.

static String getName(int codePoint)

Returns a human-readable name for the given code point, or null if the code point is unassigned.

static int getNumericValue(int codePoint)

Gets the numeric value of the specified Unicode code point.

static int getNumericValue(char c)

Returns the numeric value of the specified Unicode character.

static int getType(char c)

Gets the general Unicode category of the specified character.

static int getType(int codePoint)

Gets the general Unicode category of the specified code point.

int hashCode()

Returns an integer hash code for this object.

static char highSurrogate(int codePoint)

Returns the high surrogate for the given code point.

static boolean isAlphabetic(int codePoint)

Returns true if the given code point is alphabetic.

static boolean isBmpCodePoint(int codePoint)

Returns true if the given code point is in the Basic Multilingual Plane (BMP).

static boolean isDefined(int codePoint)

Indicates whether the specified code point is defined in the Unicode specification.

static boolean isDefined(char c)

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

static boolean isDigit(char c)

Indicates whether the specified character is a digit.

static boolean isDigit(int codePoint)

Indicates whether the specified code point is a digit.

static boolean isHighSurrogate(char ch)

Indicates whether ch is a high- (or leading-) surrogate code unit that is used for representing supplementary characters in UTF-16 encoding.

static boolean isISOControl(char c)

Indicates whether the specified character is an ISO control character.

static boolean isISOControl(int c)

Indicates whether the specified code point is an ISO control character.

static boolean isIdentifierIgnorable(char c)

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

static boolean isIdentifierIgnorable(int codePoint)

Indicates whether the specified code point is ignorable in a Java or Unicode identifier.

static boolean isIdeographic(int codePoint)

Returns true if the given code point is a CJKV ideographic character.

static boolean isJavaIdentifierPart(int codePoint)

Indicates whether the specified code point is a valid part of a Java identifier other than the first character.

static boolean isJavaIdentifierPart(char c)

Indicates whether the specified character is a valid part of a Java identifier other than the first character.

static boolean isJavaIdentifierStart(char c)

Indicates whether the specified character is a valid first character for a Java identifier.

static boolean isJavaIdentifierStart(int codePoint)

Indicates whether the specified code point is a valid first character for a Java identifier.

static boolean isJavaLetter(char c)

This method was deprecated in API level 1. Use isJavaIdentifierStart(char) instead.

static boolean isJavaLetterOrDigit(char c)

This method was deprecated in API level 1. Use isJavaIdentifierPart(char) instead.

static boolean isLetter(char c)

Indicates whether the specified character is a letter.

static boolean isLetter(int codePoint)

Indicates whether the specified code point is a letter.

static boolean isLetterOrDigit(char c)

Indicates whether the specified character is a letter or a digit.

static boolean isLetterOrDigit(int codePoint)

Indicates whether the specified code point is a letter or a digit.

static boolean isLowSurrogate(char ch)

Indicates whether ch is a low- (or trailing-) surrogate code unit that is used for representing supplementary characters in UTF-16 encoding.

static boolean isLowerCase(int codePoint)

Indicates whether the specified code point is a lower case letter.

static boolean isLowerCase(char c)

Indicates whether the specified character is a lower case letter.

static boolean isMirrored(char c)

Indicates whether the specified character is mirrored.

static boolean isMirrored(int codePoint)

Indicates whether the specified code point is mirrored.

static boolean isSpace(char c)

This method was deprecated in API level 1. Use isWhitespace(char) instead.

static boolean isSpaceChar(char c)

See isSpaceChar(int).

static boolean isSpaceChar(int codePoint)

Returns true if the given code point is a Unicode space character.

static boolean isSupplementaryCodePoint(int codePoint)

Indicates whether codePoint is within the supplementary code point range.

static boolean isSurrogate(char ch)

Returns true if the given character is a high or low surrogate.

static boolean isSurrogatePair(char high, char low)

Indicates whether the specified character pair is a valid surrogate pair.

static boolean isTitleCase(int codePoint)

Indicates whether the specified code point is a titlecase character.

static boolean isTitleCase(char c)

Indicates whether the specified character is a titlecase character.

static boolean isUnicodeIdentifierPart(int codePoint)

Indicates whether the specified code point is valid as part of a Unicode identifier other than the first character.

static boolean isUnicodeIdentifierPart(char c)

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

static boolean isUnicodeIdentifierStart(char c)

Indicates whether the specified character is a valid initial character for a Unicode identifier.

static boolean isUnicodeIdentifierStart(int codePoint)

Indicates whether the specified code point is a valid initial character for a Unicode identifier.

static boolean isUpperCase(int codePoint)

Indicates whether the specified code point is an upper case letter.

static boolean isUpperCase(char c)

Indicates whether the specified character is an upper case letter.

static boolean isValidCodePoint(int codePoint)

Indicates whether codePoint is a valid Unicode code point.

static boolean isWhitespace(char c)

See isWhitespace(int).

static boolean isWhitespace(int codePoint)

Returns true if the given code point is a Unicode whitespace character.

static char lowSurrogate(int codePoint)

Returns the low surrogate for the given code point.

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

Determines the index in the specified character sequence that is offset codePointOffset code points from index.

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

Determines the index in a subsequence of the specified character array that is offset codePointOffset code points from index.

static char reverseBytes(char c)

Reverses the order of the first and second byte in the specified character.

static char[] toChars(int codePoint)

Converts the specified Unicode code point into a UTF-16 encoded sequence and returns it as a char array.

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

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

static int toCodePoint(char high, char low)

Converts a surrogate pair into a Unicode code point.

static char toLowerCase(char c)

Returns the lower case equivalent for the specified character if the character is an upper case letter.

static int toLowerCase(int codePoint)

Returns the lower case equivalent for the specified code point if it is an upper case letter.

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 this object.

static char toTitleCase(char c)

Returns the title case equivalent for the specified character if it exists.

static int toTitleCase(int codePoint)

Returns the title case equivalent for the specified code point if it exists.

static char toUpperCase(char c)

Returns the upper case equivalent for the specified character if the character is a lower case letter.

static int toUpperCase(int codePoint)

Returns the upper case equivalent for the specified code point if the code point is a lower case letter.

static Character valueOf(char c)

Returns a Character instance for the char value passed.

Inherited methods

From class java.lang.Object
From interface java.lang.Comparable

Constants

COMBINING_SPACING_MARK

Added in API level 1
byte COMBINING_SPACING_MARK

Unicode category constant Mc.

Constant Value: 8 (0x00000008)

CONNECTOR_PUNCTUATION

Added in API level 1
byte CONNECTOR_PUNCTUATION

Unicode category constant Pc.

Constant Value: 23 (0x00000017)

CONTROL

Added in API level 1
byte CONTROL

Unicode category constant Cc.

Constant Value: 15 (0x0000000f)

CURRENCY_SYMBOL

Added in API level 1
byte CURRENCY_SYMBOL

Unicode category constant Sc.

Constant Value: 26 (0x0000001a)

DASH_PUNCTUATION

Added in API level 1
byte DASH_PUNCTUATION

Unicode category constant Pd.

Constant Value: 20 (0x00000014)

DECIMAL_DIGIT_NUMBER

Added in API level 1
byte DECIMAL_DIGIT_NUMBER

Unicode category constant Nd.

Constant Value: 9 (0x00000009)

DIRECTIONALITY_ARABIC_NUMBER

Added in API level 1
byte DIRECTIONALITY_ARABIC_NUMBER

Unicode bidirectional constant AN.

Constant Value: 6 (0x00000006)

DIRECTIONALITY_BOUNDARY_NEUTRAL

Added in API level 1
byte DIRECTIONALITY_BOUNDARY_NEUTRAL

Unicode bidirectional constant BN.

Constant Value: 9 (0x00000009)

DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

Added in API level 1
byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

Unicode bidirectional constant CS.

Constant Value: 7 (0x00000007)

DIRECTIONALITY_EUROPEAN_NUMBER

Added in API level 1
byte DIRECTIONALITY_EUROPEAN_NUMBER

Unicode bidirectional constant EN.

Constant Value: 3 (0x00000003)

DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

Added in API level 1
byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

Unicode bidirectional constant ES.

Constant Value: 4 (0x00000004)

DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

Added in API level 1
byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

Unicode bidirectional constant ET.

Constant Value: 5 (0x00000005)

DIRECTIONALITY_LEFT_TO_RIGHT

Added in API level 1
byte DIRECTIONALITY_LEFT_TO_RIGHT

Unicode bidirectional constant L.

Constant Value: 0 (0x00000000)

DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

Added in API level 1
byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

Unicode bidirectional constant LRE.

Constant Value: 14 (0x0000000e)

DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

Added in API level 1
byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

Unicode bidirectional constant LRO.

Constant Value: 15 (0x0000000f)

DIRECTIONALITY_NONSPACING_MARK

Added in API level 1
byte DIRECTIONALITY_NONSPACING_MARK

Unicode bidirectional constant NSM.

Constant Value: 8 (0x00000008)

DIRECTIONALITY_OTHER_NEUTRALS

Added in API level 1
byte DIRECTIONALITY_OTHER_NEUTRALS

Unicode bidirectional constant ON.

Constant Value: 13 (0x0000000d)

DIRECTIONALITY_PARAGRAPH_SEPARATOR

Added in API level 1
byte DIRECTIONALITY_PARAGRAPH_SEPARATOR

Unicode bidirectional constant B.

Constant Value: 10 (0x0000000a)

DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

Added in API level 1
byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

Unicode bidirectional constant PDF.

Constant Value: 18 (0x00000012)

DIRECTIONALITY_RIGHT_TO_LEFT

Added in API level 1
byte DIRECTIONALITY_RIGHT_TO_LEFT

Unicode bidirectional constant R.

Constant Value: 1 (0x00000001)

DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

Added in API level 1
byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

Unicode bidirectional constant AL.

Constant Value: 2 (0x00000002)

DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

Added in API level 1
byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

Unicode bidirectional constant RLE.

Constant Value: 16 (0x00000010)

DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

Added in API level 1
byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

Unicode bidirectional constant RLO.

Constant Value: 17 (0x00000011)

DIRECTIONALITY_SEGMENT_SEPARATOR

Added in API level 1
byte DIRECTIONALITY_SEGMENT_SEPARATOR

Unicode bidirectional constant S.

Constant Value: 11 (0x0000000b)

DIRECTIONALITY_UNDEFINED

Added in API level 1
byte DIRECTIONALITY_UNDEFINED

Unicode bidirectional constant.

Constant Value: -1 (0xffffffff)

DIRECTIONALITY_WHITESPACE

Added in API level 1
byte DIRECTIONALITY_WHITESPACE

Unicode bidirectional constant WS.

Constant Value: 12 (0x0000000c)

ENCLOSING_MARK

Added in API level 1
byte ENCLOSING_MARK

Unicode category constant Me.

Constant Value: 7 (0x00000007)

END_PUNCTUATION

Added in API level 1
byte END_PUNCTUATION

Unicode category constant Pe.

Constant Value: 22 (0x00000016)

FINAL_QUOTE_PUNCTUATION

Added in API level 1
byte FINAL_QUOTE_PUNCTUATION

Unicode category constant Pf.

Constant Value: 30 (0x0000001e)

FORMAT

Added in API level 1
byte FORMAT

Unicode category constant Cf.

Constant Value: 16 (0x00000010)

INITIAL_QUOTE_PUNCTUATION

Added in API level 1
byte INITIAL_QUOTE_PUNCTUATION

Unicode category constant Pi.

Constant Value: 29 (0x0000001d)

LETTER_NUMBER

Added in API level 1
byte LETTER_NUMBER

Unicode category constant Nl.

Constant Value: 10 (0x0000000a)

LINE_SEPARATOR

Added in API level 1
byte LINE_SEPARATOR

Unicode category constant Zl.

Constant Value: 13 (0x0000000d)

LOWERCASE_LETTER

Added in API level 1
byte LOWERCASE_LETTER

Unicode category constant Ll.

Constant Value: 2 (0x00000002)

MATH_SYMBOL

Added in API level 1
byte MATH_SYMBOL

Unicode category constant Sm.

Constant Value: 25 (0x00000019)

MAX_CODE_POINT

Added in API level 1
int MAX_CODE_POINT

The maximum code point value, U+10FFFF.

Constant Value: 1114111 (0x0010ffff)

MAX_HIGH_SURROGATE

Added in API level 1
char MAX_HIGH_SURROGATE

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

Constant Value: 56319 (0x0000dbff)

MAX_LOW_SURROGATE

Added in API level 1
char MAX_LOW_SURROGATE

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

Constant Value: 57343 (0x0000dfff)

MAX_RADIX

Added in API level 1
int MAX_RADIX

The maximum radix used for conversions between characters and integers.

Constant Value: 36 (0x00000024)

MAX_SURROGATE

Added in API level 1
char MAX_SURROGATE

The maximum value of a surrogate unit in UTF-16 encoding, '?'.

Constant Value: 57343 (0x0000dfff)

MAX_VALUE

Added in API level 1
char MAX_VALUE

The maximum Character value.

Constant Value: 65535 (0x0000ffff)

MIN_CODE_POINT

Added in API level 1
int MIN_CODE_POINT

The minimum code point value, U+0000.

Constant Value: 0 (0x00000000)

MIN_HIGH_SURROGATE

Added in API level 1
char MIN_HIGH_SURROGATE

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

Constant Value: 55296 (0x0000d800)

MIN_LOW_SURROGATE

Added in API level 1
char MIN_LOW_SURROGATE

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

Constant Value: 56320 (0x0000dc00)

MIN_RADIX

Added in API level 1
int MIN_RADIX

The minimum radix used for conversions between characters and integers.

Constant Value: 2 (0x00000002)

MIN_SUPPLEMENTARY_CODE_POINT

Added in API level 1
int MIN_SUPPLEMENTARY_CODE_POINT

The minimum value of a supplementary code point, U+010000.

Constant Value: 65536 (0x00010000)

MIN_SURROGATE

Added in API level 1
char MIN_SURROGATE

The minimum value of a surrogate unit in UTF-16 encoding, '?'.

Constant Value: 55296 (0x0000d800)

MIN_VALUE

Added in API level 1
char MIN_VALUE

The minimum Character value.

Constant Value: 0 (0x00000000)

MODIFIER_LETTER

Added in API level 1
byte MODIFIER_LETTER

Unicode category constant Lm.

Constant Value: 4 (0x00000004)

MODIFIER_SYMBOL

Added in API level 1
byte MODIFIER_SYMBOL

Unicode category constant Sk.

Constant Value: 27 (0x0000001b)

NON_SPACING_MARK

Added in API level 1
byte NON_SPACING_MARK

Unicode category constant Mn.

Constant Value: 6 (0x00000006)

OTHER_LETTER

Added in API level 1
byte OTHER_LETTER

Unicode category constant Lo.

Constant Value: 5 (0x00000005)

OTHER_NUMBER

Added in API level 1
byte OTHER_NUMBER

Unicode category constant No.

Constant Value: 11 (0x0000000b)

OTHER_PUNCTUATION

Added in API level 1
byte OTHER_PUNCTUATION

Unicode category constant Po.

Constant Value: 24 (0x00000018)

OTHER_SYMBOL

Added in API level 1
byte OTHER_SYMBOL

Unicode category constant So.

Constant Value: 28 (0x0000001c)

PARAGRAPH_SEPARATOR

Added in API level 1
byte PARAGRAPH_SEPARATOR

Unicode category constant Zp.

Constant Value: 14 (0x0000000e)

PRIVATE_USE

Added in API level 1
byte PRIVATE_USE

Unicode category constant Co.

Constant Value: 18 (0x00000012)

SIZE

Added in API level 1
int SIZE

The number of bits required to represent a Character value unsigned form.

Constant Value: 16 (0x00000010)

SPACE_SEPARATOR

Added in API level 1
byte SPACE_SEPARATOR

Unicode category constant Zs.

Constant Value: 12 (0x0000000c)

START_PUNCTUATION

Added in API level 1
byte START_PUNCTUATION

Unicode category constant Ps.

Constant Value: 21 (0x00000015)

SURROGATE

Added in API level 1
byte SURROGATE

Unicode category constant Cs.

Constant Value: 19 (0x00000013)

TITLECASE_LETTER

Added in API level 1
byte TITLECASE_LETTER

Unicode category constant Lt.

Constant Value: 3 (0x00000003)

UNASSIGNED

Added in API level 1
byte UNASSIGNED

Unicode category constant Cn.

Constant Value: 0 (0x00000000)

UPPERCASE_LETTER

Added in API level 1
byte UPPERCASE_LETTER

Unicode category constant Lu.

Constant Value: 1 (0x00000001)

Fields

TYPE

Added in API level 1
Class<Character> TYPE

The Class object that represents the primitive type char.

Public constructors

Character

Added in API level 1
Character (char value)

Constructs a new Character with the specified primitive char value.

Parameters
value char: the primitive char value to store in the new instance.

Public methods

charCount

Added in API level 1
int charCount (int codePoint)

Calculates the number of char values required to represent the specified Unicode code point. This method checks 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 int: the code point for which to calculate the number of required chars.
Returns
int 2 if codePoint >= 0x10000; 1 otherwise.

See also:

charValue

Added in API level 1
char charValue ()

Gets the primitive value of this character.

Returns
char this object's primitive value.

codePointAt

Added in API level 1
int codePointAt (char[] seq, 
                int index)

Returns the code point at index in the specified array of character units. If the unit at index is a high-surrogate unit, index + 1 is less than the length of the array and the unit at index + 1 is a low-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index is returned.

Parameters
seq char: the source array of char units.
index int: the position in seq from which to retrieve the code point.
Returns
int the Unicode code point or char value at index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if the index is negative or greater than or equal to the length of seq.

codePointAt

Added in API level 1
int codePointAt (char[] seq, 
                int index, 
                int limit)

Returns the code point at index in the specified array of character units, where index has to be less than limit. If the unit at index is a high-surrogate unit, index + 1 is less than limit and the unit at index + 1 is a low-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index is returned.

Parameters
seq char: the source array of char units.
index int: the position in seq from which to get the code point.
limit int: the index after the last unit in seq that can be used.
Returns
int the Unicode code point or char value at index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if index < 0, index >= limit, limit < 0 or if limit is greater than the length of seq.

codePointAt

Added in API level 1
int codePointAt (CharSequence seq, 
                int index)

Returns the code point at index in the specified sequence of character units. If the unit at index is a high-surrogate unit, index + 1 is less than the length of the sequence and the unit at index + 1 is a low-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index is returned.

Parameters
seq CharSequence: the source sequence of char units.
index int: the position in seq from which to retrieve the code point.
Returns
int the Unicode code point or char value at index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if the index is negative or greater than or equal to the length of seq.

codePointBefore

Added in API level 1
int codePointBefore (CharSequence seq, 
                int index)

Returns the code point that precedes index in the specified sequence of character units. If the unit at index - 1 is a low-surrogate unit, index - 2 is not negative and the unit at index - 2 is a high-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index - 1 is returned.

Parameters
seq CharSequence: the source sequence of char units.
index int: the position in seq following the code point that should be returned.
Returns
int the Unicode code point or char value before index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if the index is less than 1 or greater than the length of seq.

codePointBefore

Added in API level 1
int codePointBefore (char[] seq, 
                int index, 
                int start)

Returns the code point that precedes the index in the specified array of character units and is not less than start. If the unit at index - 1 is a low-surrogate unit, index - 2 is not less than start and the unit at index - 2 is a high-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index - 1 is returned.

Parameters
seq char: the source array of char units.
index int: the position in seq following the code point that should be returned.
start int: the index of the first element in seq.
Returns
int the Unicode code point or char value before index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if the index <= start, start < 0, index is greater than the length of seq, or if start is equal or greater than the length of seq.

codePointBefore

Added in API level 1
int codePointBefore (char[] seq, 
                int index)

Returns the code point that precedes index in the specified array of character units. If the unit at index - 1 is a low-surrogate unit, index - 2 is not negative and the unit at index - 2 is a high-surrogate unit, then the supplementary code point represented by the pair is returned; otherwise the char value at index - 1 is returned.

Parameters
seq char: the source array of char units.
index int: the position in seq following the code point that should be returned.
Returns
int the Unicode code point or char value before index in seq.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if the index is less than 1 or greater than the length of seq.

codePointCount

Added in API level 1
int codePointCount (CharSequence seq, 
                int beginIndex, 
                int endIndex)

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

Parameters
seq CharSequence: the CharSequence to look through.
beginIndex int: the inclusive index to begin counting at.
endIndex int: the exclusive index to stop counting at.
Returns
int the number of Unicode code points.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if beginIndex < 0, beginIndex > endIndex or if endIndex is greater than the length of seq.

codePointCount

Added in API level 1
int codePointCount (char[] seq, 
                int offset, 
                int count)

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

Parameters
seq char: the char array to look through
offset int: the inclusive index to begin counting at.
count int: the number of char values to look through in seq.
Returns
int the number of Unicode code points.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if offset < 0, count < 0 or if offset + count is greater than the length of seq.

compare

Added in API level 19
int compare (char lhs, 
                char rhs)

Compares two char values.

Parameters
lhs char
rhs char
Returns
int 0 if lhs = rhs, less than 0 if lhs < rhs, and greater than 0 if lhs > rhs.

compareTo

Added in API level 1
int compareTo (Character c)

Compares this object to the specified character object to determine their relative order.

Parameters
c Character: the character object to compare this object to.
Returns
int 0 if the value of this character and the value of c are equal; a positive value if the value of this character is greater than the value of c; a negative value if the value of this character is less than the value of c.

See also:

digit

Added in API level 1
int digit (char c, 
                int radix)

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

Parameters
c char: the character to determine the value of.
radix int: the radix.
Returns
int the value of c in radix if radix lies between MIN_RADIX and MAX_RADIX; -1 otherwise.

digit

Added in API level 1
int digit (int codePoint, 
                int radix)

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

Parameters
codePoint int: the character, including supplementary characters.
radix int: the radix.
Returns
int if radix lies between MIN_RADIX and MAX_RADIX then the value of the character in the radix; -1 otherwise.

equals

Added in API level 1
boolean equals (Object object)

Compares this object with the specified object and indicates if they are equal. In order to be equal, object must be an instance of Character and have the same char value as this object.

Parameters
object Object: the object to compare this double with.
Returns
boolean true if the specified object is equal to this Character; false otherwise.

forDigit

Added in API level 1
char forDigit (int digit, 
                int radix)

Returns the character which represents the specified digit in the specified radix. The radix must be between MIN_RADIX and MAX_RADIX inclusive; digit must not be negative and smaller than radix. If any of these conditions does not hold, 0 is returned.

Parameters
digit int: the integer value.
radix int: the radix.
Returns
char the character which represents the digit in the radix.

getDirectionality

Added in API level 1
byte getDirectionality (int codePoint)

Returns the Unicode directionality of the given code point. This will be one of the DIRECTIONALITY_ constants. For characters whose directionality is undefined, or whose directionality has no appropriate constant in this class, DIRECTIONALITY_UNDEFINED is returned.

Parameters
codePoint int
Returns
byte

getDirectionality

Added in API level 1
byte getDirectionality (char c)

Gets the Unicode directionality of the specified character.

Parameters
c char: the character to get the directionality of.
Returns
byte the Unicode directionality of c.

getName

Added in API level 19
String getName (int codePoint)

Returns a human-readable name for the given code point, or null if the code point is unassigned.

As a fallback mechanism this method returns strings consisting of the Unicode block name (with underscores replaced by spaces), a single space, and the uppercase hex value of the code point, using as few digits as necessary.

Examples:

  • Character.getName(0) returns "NULL".
  • Character.getName('e') returns "LATIN SMALL LETTER E".
  • Character.getName('٦') returns "ARABIC-INDIC DIGIT SIX".
  • Character.getName(0xe000) returns "PRIVATE USE AREA E000".

Note that the exact strings returned will vary from release to release.

Parameters
codePoint int
Returns
String
Throws
IllegalArgumentException if codePoint is not a valid code point.

getNumericValue

Added in API level 1
int getNumericValue (int codePoint)

Gets the numeric value of the specified Unicode code point. For example, the code point 'Ⅻ' stands for the Roman number XII, which has the numeric value 12.

There are two points of divergence between this method and the Unicode specification. This method treats the letters a-z (in both upper and lower cases, and their full-width variants) as numbers from 10 to 35. The Unicode specification also supports the idea of code points with non-integer numeric values; this method does not (except to the extent of returning -2 for such code points).

Parameters
codePoint int: the code point
Returns
int a non-negative numeric integer value if a numeric value for codePoint exists, -1 if there is no numeric value for codePoint, -2 if the numeric value can not be represented with an integer.

getNumericValue

Added in API level 1
int getNumericValue (char c)

Returns the numeric value of the specified Unicode character. See getNumericValue(int).

Parameters
c char: the character
Returns
int a non-negative numeric integer value if a numeric value for c exists, -1 if there is no numeric value for c, -2 if the numeric value can not be represented as an integer.

getType

Added in API level 1
int getType (char c)

Gets the general Unicode category of the specified character.

Parameters
c char: the character to get the category of.
Returns
int the Unicode category of c.

getType

Added in API level 1
int getType (int codePoint)

Gets the general Unicode category of the specified code point.

Parameters
codePoint int: the Unicode code point to get the category of.
Returns
int the Unicode category of codePoint.

hashCode

Added in API level 1
int hashCode ()

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
int this object's hash code.

highSurrogate

Added in API level 19
char highSurrogate (int codePoint)

Returns the high surrogate for the given code point. The result is meaningless if the given code point is not a supplementary character.

Parameters
codePoint int
Returns
char

isAlphabetic

Added in API level 19
boolean isAlphabetic (int codePoint)

Returns true if the given code point is alphabetic. That is, if it is in any of the Lu, Ll, Lt, Lm, Lo, Nl, or Other_Alphabetic categories.

Parameters
codePoint int
Returns
boolean

isBmpCodePoint

Added in API level 19
boolean isBmpCodePoint (int codePoint)

Returns true if the given code point is in the Basic Multilingual Plane (BMP). Such code points can be represented by a single char.

Parameters
codePoint int
Returns
boolean

isDefined

Added in API level 1
boolean isDefined (int codePoint)

Indicates whether the specified code point is defined in the Unicode specification.

Parameters
codePoint int: the code point to check.
Returns
boolean true if the general Unicode category of the code point is not UNASSIGNED; false otherwise.

isDefined

Added in API level 1
boolean isDefined (char c)

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

Parameters
c char: the character to check.
Returns
boolean true if the general Unicode category of the character is not UNASSIGNED; false otherwise.

isDigit

Added in API level 1
boolean isDigit (char c)

Indicates whether the specified character is a digit.

Parameters
c char: the character to check.
Returns
boolean true if c is a digit; false otherwise.

isDigit

Added in API level 1
boolean isDigit (int codePoint)

Indicates whether the specified code point is a digit.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a digit; false otherwise.

isHighSurrogate

Added in API level 1
boolean isHighSurrogate (char ch)

Indicates whether ch is a high- (or leading-) surrogate code unit that is used for representing supplementary characters in UTF-16 encoding.

Parameters
ch char: the character to test.
Returns
boolean true if ch is a high-surrogate code unit; false otherwise.

See also:

isISOControl

Added in API level 1
boolean isISOControl (char c)

Indicates whether the specified character is an ISO control character.

Parameters
c char: the character to check.
Returns
boolean true if c is an ISO control character; false otherwise.

isISOControl

Added in API level 1
boolean isISOControl (int c)

Indicates whether the specified code point is an ISO control character.

Parameters
c int: the code point to check.
Returns
boolean true if c is an ISO control character; false otherwise.

isIdentifierIgnorable

Added in API level 1
boolean isIdentifierIgnorable (char c)

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

Parameters
c char: the character to check.
Returns
boolean true if c is ignorable; false otherwise.

isIdentifierIgnorable

Added in API level 1
boolean isIdentifierIgnorable (int codePoint)

Indicates whether the specified code point is ignorable in a Java or Unicode identifier.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is ignorable; false otherwise.

isIdeographic

Added in API level 19
boolean isIdeographic (int codePoint)

Returns true if the given code point is a CJKV ideographic character.

Parameters
codePoint int
Returns
boolean

isJavaIdentifierPart

Added in API level 1
boolean isJavaIdentifierPart (int codePoint)

Indicates whether the specified code point is a valid part of a Java identifier other than the first character.

Parameters
codePoint int: the code point to check.
Returns
boolean true if c is valid as part of a Java identifier; false otherwise.

isJavaIdentifierPart

Added in API level 1
boolean isJavaIdentifierPart (char c)

Indicates whether the specified character is a valid part of a Java identifier other than the first character.

Parameters
c char: the character to check.
Returns
boolean true if c is valid as part of a Java identifier; false otherwise.

isJavaIdentifierStart

Added in API level 1
boolean isJavaIdentifierStart (char c)

Indicates whether the specified character is a valid first character for a Java identifier.

Parameters
c char: the character to check.
Returns
boolean true if c is a valid first character of a Java identifier; false otherwise.

isJavaIdentifierStart

Added in API level 1
boolean isJavaIdentifierStart (int codePoint)

Indicates whether the specified code point is a valid first character for a Java identifier.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a valid start of a Java identifier; false otherwise.

isJavaLetter

Added in API level 1
boolean isJavaLetter (char c)

This method was deprecated in API level 1.
Use isJavaIdentifierStart(char) instead.

Indicates whether the specified character is a Java letter.

Parameters
c char: the character to check.
Returns
boolean true if c is a Java letter; false otherwise.

isJavaLetterOrDigit

Added in API level 1
boolean isJavaLetterOrDigit (char c)

This method was deprecated in API level 1.
Use isJavaIdentifierPart(char) instead.

Indicates whether the specified character is a Java letter or digit character.

Parameters
c char: the character to check.
Returns
boolean true if c is a Java letter or digit; false otherwise.

isLetter

Added in API level 1
boolean isLetter (char c)

Indicates whether the specified character is a letter.

Parameters
c char: the character to check.
Returns
boolean true if c is a letter; false otherwise.

isLetter

Added in API level 1
boolean isLetter (int codePoint)

Indicates whether the specified code point is a letter.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a letter; false otherwise.

isLetterOrDigit

Added in API level 1
boolean isLetterOrDigit (char c)

Indicates whether the specified character is a letter or a digit.

Parameters
c char: the character to check.
Returns
boolean true if c is a letter or a digit; false otherwise.

isLetterOrDigit

Added in API level 1
boolean isLetterOrDigit (int codePoint)

Indicates whether the specified code point is a letter or a digit.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a letter or a digit; false otherwise.

isLowSurrogate

Added in API level 1
boolean isLowSurrogate (char ch)

Indicates whether ch is a low- (or trailing-) surrogate code unit that is used for representing supplementary characters in UTF-16 encoding.

Parameters
ch char: the character to test.
Returns
boolean true if ch is a low-surrogate code unit; false otherwise.

See also:

isLowerCase

Added in API level 1
boolean isLowerCase (int codePoint)

Indicates whether the specified code point is a lower case letter.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a lower case letter; false otherwise.

isLowerCase

Added in API level 1
boolean isLowerCase (char c)

Indicates whether the specified character is a lower case letter.

Parameters
c char: the character to check.
Returns
boolean true if c is a lower case letter; false otherwise.

isMirrored

Added in API level 1
boolean isMirrored (char c)

Indicates whether the specified character is mirrored.

Parameters
c char: the character to check.
Returns
boolean true if c is mirrored; false otherwise.

isMirrored

Added in API level 1
boolean isMirrored (int codePoint)

Indicates whether the specified code point is mirrored.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is mirrored, false otherwise.

isSpace

Added in API level 1
boolean isSpace (char c)

This method was deprecated in API level 1.
Use isWhitespace(char) instead.

Use isWhitespace(char) instead.

Parameters
c char
Returns
boolean

isSpaceChar

Added in API level 1
boolean isSpaceChar (char c)

See isSpaceChar(int).

Parameters
c char
Returns
boolean

isSpaceChar

Added in API level 1
boolean isSpaceChar (int codePoint)

Returns true if the given code point is a Unicode space character. The exact set of characters considered as whitespace varies with Unicode version. Note that non-breaking spaces are considered whitespace. Note also that line separators are not considered whitespace; see isWhitespace(char) for an alternative.

Parameters
codePoint int
Returns
boolean

isSupplementaryCodePoint

Added in API level 1
boolean isSupplementaryCodePoint (int codePoint)

Indicates whether codePoint is within the supplementary code point range.

Parameters
codePoint int: the code point to test.
Returns
boolean true if codePoint is within the supplementary code point range; false otherwise.

isSurrogate

Added in API level 19
boolean isSurrogate (char ch)

Returns true if the given character is a high or low surrogate.

Parameters
ch char
Returns
boolean

isSurrogatePair

Added in API level 1
boolean isSurrogatePair (char high, 
                char low)

Indicates whether the specified character pair is a valid surrogate pair.

Parameters
high char: the high surrogate unit to test.
low char: the low surrogate unit to test.
Returns
boolean true if high is a high-surrogate code unit and low is a low-surrogate code unit; false otherwise.

See also:

isTitleCase

Added in API level 1
boolean isTitleCase (int codePoint)

Indicates whether the specified code point is a titlecase character.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a titlecase character, false otherwise.

isTitleCase

Added in API level 1
boolean isTitleCase (char c)

Indicates whether the specified character is a titlecase character.

Parameters
c char: the character to check.
Returns
boolean true if c is a titlecase character, false otherwise.

isUnicodeIdentifierPart

Added in API level 1
boolean isUnicodeIdentifierPart (int codePoint)

Indicates whether the specified code point is valid as part of a Unicode identifier other than the first character.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is valid as part of a Unicode identifier; false otherwise.

isUnicodeIdentifierPart

Added in API level 1
boolean isUnicodeIdentifierPart (char c)

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

Parameters
c char: the character to check.
Returns
boolean true if c is valid as part of a Unicode identifier; false otherwise.

isUnicodeIdentifierStart

Added in API level 1
boolean isUnicodeIdentifierStart (char c)

Indicates whether the specified character is a valid initial character for a Unicode identifier.

Parameters
c char: the character to check.
Returns
boolean true if c is a valid first character for a Unicode identifier; false otherwise.

isUnicodeIdentifierStart

Added in API level 1
boolean isUnicodeIdentifierStart (int codePoint)

Indicates whether the specified code point is a valid initial character for a Unicode identifier.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a valid first character for a Unicode identifier; false otherwise.

isUpperCase

Added in API level 1
boolean isUpperCase (int codePoint)

Indicates whether the specified code point is an upper case letter.

Parameters
codePoint int: the code point to check.
Returns
boolean true if codePoint is a upper case letter; false otherwise.

isUpperCase

Added in API level 1
boolean isUpperCase (char c)

Indicates whether the specified character is an upper case letter.

Parameters
c char: the character to check.
Returns
boolean true if c is a upper case letter; false otherwise.

isValidCodePoint

Added in API level 1
boolean isValidCodePoint (int codePoint)

Indicates whether codePoint is a valid Unicode code point.

Parameters
codePoint int: the code point to test.
Returns
boolean true if codePoint is a valid Unicode code point; false otherwise.

isWhitespace

Added in API level 1
boolean isWhitespace (char c)

See isWhitespace(int).

Parameters
c char
Returns
boolean

isWhitespace

Added in API level 1
boolean isWhitespace (int codePoint)

Returns true if the given code point is a Unicode whitespace character. The exact set of characters considered as whitespace varies with Unicode version. Note that non-breaking spaces are not considered whitespace. Note also that line separators are considered whitespace; see isSpaceChar(char) for an alternative.

Parameters
codePoint int
Returns
boolean

lowSurrogate

Added in API level 19
char lowSurrogate (int codePoint)

Returns the low surrogate for the given code point. The result is meaningless if the given code point is not a supplementary character.

Parameters
codePoint int
Returns
char

offsetByCodePoints

Added in API level 1
int offsetByCodePoints (CharSequence seq, 
                int index, 
                int codePointOffset)

Determines the index in the specified character sequence that is offset codePointOffset code points from index.

Parameters
seq CharSequence: the character sequence to find the index in.
index int: the start index in seq.
codePointOffset int: the number of code points to look backwards or forwards; may be a negative or positive value.
Returns
int the index in seq that is codePointOffset code points away from index.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if index < 0, index is greater than the length of seq, or if there are not enough values in seq to skip codePointOffset code points forwards or backwards (if codePointOffset is negative) from index.

offsetByCodePoints

Added in API level 1
int offsetByCodePoints (char[] seq, 
                int start, 
                int count, 
                int index, 
                int codePointOffset)

Determines the index in a subsequence of the specified character array that is offset codePointOffset code points from index. The subsequence is delineated by start and count.

Parameters
seq char: the character array to find the index in.
start int: the inclusive index that marks the beginning of the subsequence.
count int: the number of char values to include within the subsequence.
index int: the start index in the subsequence of the char array.
codePointOffset int: the number of code points to look backwards or forwards; may be a negative or positive value.
Returns
int the index in seq that is codePointOffset code points away from index.
Throws
NullPointerException if seq is null.
IndexOutOfBoundsException if start < 0, count < 0, index < start, index > start + count, start + count is greater than the length of seq, or if there are not enough values in seq to skip codePointOffset code points forward or backward (if codePointOffset is negative) from index.

reverseBytes

Added in API level 1
char reverseBytes (char c)

Reverses the order of the first and second byte in the specified character.

Parameters
c char: the character to reverse.
Returns
char the character with reordered bytes.

toChars

Added in API level 1
char[] toChars (int codePoint)

Converts the specified Unicode code point into a UTF-16 encoded sequence and returns it as a char array.

Parameters
codePoint int: the Unicode code point to encode.
Returns
char[] the UTF-16 encoded char sequence. If codePoint is a supplementary code point, then the returned array contains two characters, otherwise it contains just one character.
Throws
IllegalArgumentException if codePoint is not a valid code point.

toChars

Added in API level 1
int toChars (int codePoint, 
                char[] dst, 
                int dstIndex)

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

Parameters
codePoint int: the Unicode code point to encode.
dst char: the destination array to copy the encoded value into.
dstIndex int: the index in dst from where to start copying.
Returns
int the number of char value units copied into dst.
Throws
IllegalArgumentException if codePoint is not a valid 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.

toCodePoint

Added in API level 1
int toCodePoint (char high, 
                char low)

Converts a surrogate pair into a Unicode code point. This method assumes 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 char: the high surrogate unit.
low char: the low surrogate unit.
Returns
int the Unicode code point corresponding to the surrogate unit pair.

See also:

toLowerCase

Added in API level 1
char toLowerCase (char c)

Returns the lower case equivalent for the specified character if the character is an upper case letter. Otherwise, the specified character is returned unchanged.

Parameters
c char: the character
Returns
char if c is an upper case character then its lower case counterpart, otherwise just c.

toLowerCase

Added in API level 1
int toLowerCase (int codePoint)

Returns the lower case equivalent for the specified code point if it is an upper case letter. Otherwise, the specified code point is returned unchanged.

Parameters
codePoint int: the code point to check.
Returns
int if codePoint is an upper case character then its lower case counterpart, otherwise just codePoint.

toString

Added in API level 1
String toString (char value)

Converts the specified character to its string representation.

Parameters
value char: the character to convert.
Returns
String the character converted to a string.

toString

Added in API level 1
String toString ()

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
String a printable representation of this object.

toTitleCase

Added in API level 1
char toTitleCase (char c)

Returns the title case equivalent for the specified character if it exists. Otherwise, the specified character is returned unchanged.

Parameters
c char: the character to convert.
Returns
char the title case equivalent of c if it exists, otherwise c.

toTitleCase

Added in API level 1
int toTitleCase (int codePoint)

Returns the title case equivalent for the specified code point if it exists. Otherwise, the specified code point is returned unchanged.

Parameters
codePoint int: the code point to convert.
Returns
int the title case equivalent of codePoint if it exists, otherwise codePoint.

toUpperCase

Added in API level 1
char toUpperCase (char c)

Returns the upper case equivalent for the specified character if the character is a lower case letter. Otherwise, the specified character is returned unchanged.

Parameters
c char: the character to convert.
Returns
char if c is a lower case character then its upper case counterpart, otherwise just c.

toUpperCase

Added in API level 1
int toUpperCase (int codePoint)

Returns the upper case equivalent for the specified code point if the code point is a lower case letter. Otherwise, the specified code point is returned unchanged.

Parameters
codePoint int: the code point to convert.
Returns
int if codePoint is a lower case character then its upper case counterpart, otherwise just codePoint.

valueOf

Added in API level 1
Character valueOf (char c)

Returns a Character instance for the char value passed.

If it is not necessary to get a new Character instance, it is recommended to use this method instead of the constructor, since it maintains a cache of instances which may result in better performance.

Parameters
c char: the char value for which to get a Character instance.
Returns
Character the Character instance for c.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.