Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Character

  1. Object
  2. Character

ImplementsComparable<Character>

The Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. In addition, this class provides several methods for determining the type of a character and converting characters from uppercase to lowercase and vice versa. Character information is based on the Unicode Standard, version 3.0. However, in order to reduce footprint, by default the character property and case conversion operations in CLDC are available only for the ISO Latin-1 range of characters. Other Unicode character blocks can be supported as necessary. Since: JDK1.0, CLDC 1.0

Fields

public static final int MAX_RADIX = 36The maximum radix available for conversion to and from Strings.
public static final char MAX_VALUE = '￿'The constant value of this field is the largest value of type char.
public static final int MIN_RADIX = 2The minimum radix available for conversion to and from Strings.
public static final char MIN_VALUE = '\u0000'The constant value of this field is the smallest value of type char.
public static final char MIN_HIGH_SURROGATE = '�'Minimum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '�'.
public static final char MAX_HIGH_SURROGATE = '�'Maximum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '�'.
public static final char MIN_LOW_SURROGATE = '�'Minimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '�'.
public static final char MAX_LOW_SURROGATE = '�'Maximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '�'.
public static final char MIN_SURROGATE = '�'Minimum value of a surrogate unit in UTF-16 encoding - '�'.
public static final char MAX_SURROGATE = '�'Maximum value of a surrogate unit in UTF-16 encoding - '�'.
public static final int MIN_SUPPLEMENTARY_CODE_POINT = 65536Minimum value of a supplementary code point - U+010000.
public static final int MIN_CODE_POINT = 0Minimum code point value - U+0000.
public static final int MAX_CODE_POINT = 1114111Maximum code point value - U+10FFFF.
public static final int SIZE = 16Constant for the number of bits to represent a char in two’s compliment form.
public static final Class<Character> TYPE
public static final byte UNASSIGNED = 0
public static final byte UPPERCASE_LETTER = 1
public static final byte LOWERCASE_LETTER = 2
public static final byte TITLECASE_LETTER = 3
public static final byte MODIFIER_LETTER = 4
public static final byte OTHER_LETTER = 5
public static final byte NON_SPACING_MARK = 6
public static final byte ENCLOSING_MARK = 7
public static final byte COMBINING_SPACING_MARK = 8
public static final byte DECIMAL_DIGIT_NUMBER = 9
public static final byte LETTER_NUMBER = 10
public static final byte OTHER_NUMBER = 11
public static final byte SPACE_SEPARATOR = 12
public static final byte LINE_SEPARATOR = 13
public static final byte PARAGRAPH_SEPARATOR = 14
public static final byte CONTROL = 15
public static final byte FORMAT = 16
public static final byte PRIVATE_USE = 17
public static final byte SURROGATE = 19
public static final byte DASH_PUNCTUATION = 20
public static final byte START_PUNCTUATION = 21
public static final byte END_PUNCTUATION = 22
public static final byte CONNECTOR_PUNCTUATION = 23
public static final byte OTHER_PUNCTUATION = 24
public static final byte MATH_SYMBOL = 25
public static final byte CURRENCY_SYMBOL = 26
public static final byte MODIFIER_SYMBOL = 27
public static final byte OTHER_SYMBOL = 28
public static final byte INITIAL_QUOTE_PUNCTUATION = 29
public static final byte FINAL_QUOTE_PUNCTUATION = 30
public static final byte DIRECTIONALITY_UNDEFINED = -1
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5
public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6
public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7
public static final byte DIRECTIONALITY_NONSPACING_MARK = 8
public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9
public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10
public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11
public static final byte DIRECTIONALITY_WHITESPACE = 12
public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17
public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18
public static final int BYTES = 2The size of a char in bytes.

Constructors

public Character(char value)Constructs a Character object and initializes it so that it represents the primitive value argument.

Methods

public char charValue()Returns the value of this Character object.
public static int digit(char ch, int radix)Returns the numeric value of the character ch in the specified radix.
public boolean equals(Object obj)Compares this object against the specified object.
public int hashCode()Returns a hash code for this Character.
public static boolean isDigit(char ch)Determines if the specified character is a digit.
public static boolean isJavaIdentifierStart(char ch)Determines whether the character can start a Java identifier.
public static boolean isJavaIdentifierPart(char ch)Determines whether the character can occur in a Java identifier.
public static boolean isJavaIdentifierStart(int codePoint)Determines whether the Unicode code point can start a Java identifier.
public static boolean isJavaIdentifierPart(int codePoint)Determines whether the Unicode code point can occur in a Java identifier.
public static boolean isLowerCase(char ch)Determines if the specified character is a lowercase character.
public static boolean isUpperCase(char ch)Determines if the specified character is an uppercase character.
public static char toLowerCase(char ch)The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.
public String toString()Returns a String object representing this character’s value.
public static char toUpperCase(char ch)Converts the character argument to uppercase; if the character has no uppercase equivalent, the character itself is returned.
public static boolean isValidCodePoint(int codePoint)A test for determining if the codePoint is a valid Unicode code point.
public static boolean isSupplementaryCodePoint(int codePoint)A test for determining if the codePoint is within the supplementary code point range.
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.
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.
public static boolean isSurrogatePair(char high, char low)A test for determining if the char pair is a valid surrogate pair.
public static int charCount(int codePoint)Calculates the number of char values required to represent the Unicode code point.
public static int toCodePoint(char high, char low)Converts a surrogate pair into a Unicode code point.
public static int codePointAt(CharSequence seq, int index)Returns the code point at the index in the CharSequence.
public static int codePointAt(char[] seq, int index)Returns the code point at the index in the char[].
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.
public static int codePointBefore(CharSequence seq, int index)Returns the Unicode code point that proceeds the index in the CharSequence.
public static int codePointBefore(char[] seq, int index)Returns the Unicode code point that proceeds the index in the char[].
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.
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.
public static char[] toChars(int codePoint)Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence that is returned as a char[].
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.
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.
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.
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.
public static char reverseBytes(char c)Reverse the order of the first and second bytes in character
public static Character valueOf(char i)Returns the object instance of i
public static boolean isWhitespace(char c)See #isWhitespace(int).
public static boolean isSpace(char ch)
public static boolean isSpaceChar(char ch)
public static boolean isWhitespace(int codePoint)Returns true if the given code point is a Unicode whitespace character.
public static int toTitleCase(int codePoint)
public static char toTitleCase(char c)
public static int digit(int codePoint, int radix)
public static boolean isLetterOrDigit(char ch)
public static boolean isLetterOrDigit(int codePoint)
public static boolean isLetter(char ch)
public static boolean isLetter(int codePoint)
public static boolean isIdentifierIgnorable(char ch)
public static boolean isIdentifierIgnorable(int codePoint)
public static boolean isDigit(int codePoint)
public static boolean isLowerCase(int codePoint)
public static boolean isUpperCase(int codePoint)
public static int toLowerCase(int codePoint)
public static int toUpperCase(int codePoint)
public static char highSurrogate(int codePoint)
public static char lowSurrogate(int codePoint)
public static boolean isSpaceChar(int codePoint)Whether the code point is a Unicode space separator, line separator or paragraph separator.
public static byte getDirectionality(char ch)
public static int getType(char c)
public static boolean isBmpCodePoint(int codePoint)
public static boolean isSurrogate(char ch)
public static int getType(int codePoint)
public int compareTo(Character another)Compares this object to the specified object to determine their relative order.
public static String toString(char c)A one-char string of c.
public static String toString(int codePoint)The string of the code point: one char, or a surrogate pair.
public static int hashCode(char value)The char itself, as the JDK hashes it.
public static int compare(char x, char y)x - y.
public static boolean isISOControl(char ch)Whether the char is an ISO control character: U+0000 to U+001F or U+007F to U+009F.
public static boolean isISOControl(int codePoint)Whether the code point is an ISO control character.
public static char forDigit(int digit, int radix)The char of digit in radix, a lower case letter from 10 on, or U+0000 when either is out of range.
public static int getNumericValue(char ch)The value of a digit, or of a Latin letter read as a digit of base 36, or -1.
public static int getNumericValue(int codePoint)The value of a digit, or of a Latin letter read as a digit of base 36, or -1.
public static boolean isAlphabetic(int codePoint)Whether the code point is alphabetic.
public static boolean isDefined(char ch)Whether the char has a category in this runtime’s classification.
public static boolean isDefined(int codePoint)Whether the code point has a category in this runtime’s classification.
public static boolean isIdeographic(int codePoint)Whether the code point is a CJK ideograph.
public static boolean isTitleCase(char ch)Whether the char is a title case letter.
public static boolean isTitleCase(int codePoint)Whether the code point is a title case letter.
public static boolean isMirrored(char ch)Whether the char is mirrored in right-to-left text: the ASCII brackets and the guillemets.
public static boolean isMirrored(int codePoint)Whether the code point is mirrored in right-to-left text.
public static boolean isJavaLetter(char ch)Deprecated As isJavaIdentifierStart(char).
public static boolean isJavaLetterOrDigit(char ch)Deprecated As isJavaIdentifierPart(char).
public static boolean isUnicodeIdentifierStart(char ch)Whether the char may start a Unicode identifier.
public static boolean isUnicodeIdentifierStart(int codePoint)Whether the code point may start a Unicode identifier: a letter.
public static boolean isUnicodeIdentifierPart(char ch)Whether the char may continue a Unicode identifier.
public static boolean isUnicodeIdentifierPart(int codePoint)Whether the code point may continue a Unicode identifier: a letter, a digit, connecting punctuation or an ignorable character.

Inherited methods

Field details

MAX_RADIX

public static final int MAX_RADIX = 36
The maximum radix available for conversion to and from Strings. See Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values

MAX_VALUE

public static final char MAX_VALUE = '￿'
The constant value of this field is the largest value of type char. Since: JDK1.0.2 See Also:Constant Field Values

MIN_RADIX

public static final int MIN_RADIX = 2
The minimum radix available for conversion to and from Strings. See Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values

MIN_VALUE

public static final char MIN_VALUE = '\u0000'
The constant value of this field is the smallest value of type char. Since: JDK1.0.2 See Also:Constant Field Values

MIN_HIGH_SURROGATE

public static final char MIN_HIGH_SURROGATE = '�'
Minimum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '�'.

MAX_HIGH_SURROGATE

public static final char MAX_HIGH_SURROGATE = '�'
Maximum value of a high surrogate or leading surrogate unit in UTF-16 encoding - '�'.

MIN_LOW_SURROGATE

public static final char MIN_LOW_SURROGATE = '�'
Minimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '�'.

MAX_LOW_SURROGATE

public static final char MAX_LOW_SURROGATE = '�'
Maximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '�'.

MIN_SURROGATE

public static final char MIN_SURROGATE = '�'
Minimum value of a surrogate unit in UTF-16 encoding - '�'.

MAX_SURROGATE

public static final char MAX_SURROGATE = '�'
Maximum value of a surrogate unit in UTF-16 encoding - '�'.

MIN_SUPPLEMENTARY_CODE_POINT

public static final int MIN_SUPPLEMENTARY_CODE_POINT = 65536
Minimum value of a supplementary code point - U+010000.

MIN_CODE_POINT

public static final int MIN_CODE_POINT = 0
Minimum code point value - U+0000.

MAX_CODE_POINT

public static final int MAX_CODE_POINT = 1114111
Maximum code point value - U+10FFFF.

SIZE

public static final int SIZE = 16
Constant for the number of bits to represent a char in two’s compliment form.

TYPE

public static final Class<Character> TYPE

UNASSIGNED

public static final byte UNASSIGNED = 0

UPPERCASE_LETTER

public static final byte UPPERCASE_LETTER = 1

LOWERCASE_LETTER

public static final byte LOWERCASE_LETTER = 2

TITLECASE_LETTER

public static final byte TITLECASE_LETTER = 3

MODIFIER_LETTER

public static final byte MODIFIER_LETTER = 4

OTHER_LETTER

public static final byte OTHER_LETTER = 5

NON_SPACING_MARK

public static final byte NON_SPACING_MARK = 6

ENCLOSING_MARK

public static final byte ENCLOSING_MARK = 7

COMBINING_SPACING_MARK

public static final byte COMBINING_SPACING_MARK = 8

DECIMAL_DIGIT_NUMBER

public static final byte DECIMAL_DIGIT_NUMBER = 9

LETTER_NUMBER

public static final byte LETTER_NUMBER = 10

OTHER_NUMBER

public static final byte OTHER_NUMBER = 11

SPACE_SEPARATOR

public static final byte SPACE_SEPARATOR = 12

LINE_SEPARATOR

public static final byte LINE_SEPARATOR = 13

PARAGRAPH_SEPARATOR

public static final byte PARAGRAPH_SEPARATOR = 14

CONTROL

public static final byte CONTROL = 15

FORMAT

public static final byte FORMAT = 16

PRIVATE_USE

public static final byte PRIVATE_USE = 17

SURROGATE

public static final byte SURROGATE = 19

DASH_PUNCTUATION

public static final byte DASH_PUNCTUATION = 20

START_PUNCTUATION

public static final byte START_PUNCTUATION = 21

END_PUNCTUATION

public static final byte END_PUNCTUATION = 22

CONNECTOR_PUNCTUATION

public static final byte CONNECTOR_PUNCTUATION = 23

OTHER_PUNCTUATION

public static final byte OTHER_PUNCTUATION = 24

MATH_SYMBOL

public static final byte MATH_SYMBOL = 25

CURRENCY_SYMBOL

public static final byte CURRENCY_SYMBOL = 26

MODIFIER_SYMBOL

public static final byte MODIFIER_SYMBOL = 27

OTHER_SYMBOL

public static final byte OTHER_SYMBOL = 28

INITIAL_QUOTE_PUNCTUATION

public static final byte INITIAL_QUOTE_PUNCTUATION = 29

FINAL_QUOTE_PUNCTUATION

public static final byte FINAL_QUOTE_PUNCTUATION = 30

DIRECTIONALITY_UNDEFINED

public static final byte DIRECTIONALITY_UNDEFINED = -1

DIRECTIONALITY_LEFT_TO_RIGHT

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0

DIRECTIONALITY_RIGHT_TO_LEFT

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1

DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2

DIRECTIONALITY_EUROPEAN_NUMBER

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3

DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4

DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5

DIRECTIONALITY_ARABIC_NUMBER

public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6

DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7

DIRECTIONALITY_NONSPACING_MARK

public static final byte DIRECTIONALITY_NONSPACING_MARK = 8

DIRECTIONALITY_BOUNDARY_NEUTRAL

public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9

DIRECTIONALITY_PARAGRAPH_SEPARATOR

public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10

DIRECTIONALITY_SEGMENT_SEPARATOR

public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11

DIRECTIONALITY_WHITESPACE

public static final byte DIRECTIONALITY_WHITESPACE = 12

DIRECTIONALITY_OTHER_NEUTRALS

public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13

DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14

DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15

DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16

DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17

DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18

BYTES

public static final int BYTES = 2
The size of a char in bytes.

Constructor details

Character

public Character(char value)
Constructs a Character object and initializes it so that it represents the primitive value argument. value - value for the new Character object.

Method details

charValue

public char charValue()
Returns the value of this Character object.

digit

public static int digit(char ch, int radix)
Returns the numeric value of the character ch in the specified radix.

equals

public boolean equals(Object obj)
Compares this object against the specified object. The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.

hashCode

public int hashCode()
Returns a hash code for this Character.

isDigit

public static boolean isDigit(char ch)
Determines if the specified character is a digit.

isJavaIdentifierStart

public static boolean isJavaIdentifierStart(char ch)
Determines whether the character can start a Java identifier.

Parameters

ch char
the character to test

Returns

true if the character can start a Java identifier

isJavaIdentifierPart

public static boolean isJavaIdentifierPart(char ch)
Determines whether the character can occur in a Java identifier.

Parameters

ch char
the character to test

Returns

true if the character can occur in a Java identifier

isJavaIdentifierStart

public static boolean isJavaIdentifierStart(int codePoint)
Determines whether the Unicode code point can start a Java identifier.

Parameters

codePoint int
the Unicode code point to test

Returns

true if the code point can start a Java identifier

isJavaIdentifierPart

public static boolean isJavaIdentifierPart(int codePoint)
Determines whether the Unicode code point can occur in a Java identifier.

Parameters

codePoint int
the Unicode code point to test

Returns

true if the code point can occur in a Java identifier

isLowerCase

public static boolean isLowerCase(char ch)
Determines if the specified character is a lowercase character. Note that by default CLDC only supports the ISO Latin-1 range of characters. Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF), the following are lowercase: a b c d e f g h i j k l m n o p q r s t u v w x y z u00DF u00E0 u00E1 u00E2 u00E3 u00E4 u00E5 u00E6 u00E7 u00E8 u00E9 u00EA u00EB u00EC u00ED u00EE u00EF u00F0 u00F1 u00F2 u00F3 u00F4 u00F5 u00F6 u00F8 u00F9 u00FA u00FB u00FC u00FD u00FE u00FF

isUpperCase

public static boolean isUpperCase(char ch)
Determines if the specified character is an uppercase character. Note that by default CLDC only supports the ISO Latin-1 range of characters. Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF), the following are uppercase: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z u00C0 u00C1 u00C2 u00C3 u00C4 u00C5 u00C6 u00C7 u00C8 u00C9 u00CA u00CB u00CC u00CD u00CE u00CF u00D0 u00D1 u00D2 u00D3 u00D4 u00D5 u00D6 u00D8 u00D9 u00DA u00DB u00DC u00DD u00DE

toLowerCase

public static char toLowerCase(char ch)
The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned. Note that by default CLDC only supports the ISO Latin-1 range of characters.

toString

public String toString()
Returns a String object representing this character’s value. Converts this Character object to a string. The result is a string whose length is 1. The string’s sole component is the primitive char value represented by this object.

toUpperCase

public static char toUpperCase(char ch)
Converts the character argument to uppercase; if the character has no uppercase equivalent, the character itself is returned. Note that by default CLDC only supports the ISO Latin-1 range of characters.

isValidCodePoint

public static boolean isValidCodePoint(int codePoint)
A test for determining if the codePoint is a valid Unicode code point.

Parameters

codePoint int
The code point to test.

Returns

A boolean value.

isSupplementaryCodePoint

public static boolean isSupplementaryCodePoint(int codePoint)
A test for determining if the codePoint is within the supplementary code point range.

Parameters

codePoint int
The code point to test.

Returns

A boolean value.

isHighSurrogate

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 char
The char unit to test.

Returns

A boolean value.

isLowSurrogate

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 char
The char unit to test.

Returns

A boolean value.

isSurrogatePair

public static boolean isSurrogatePair(char high, char low)
A test for determining if the char pair is a valid surrogate pair.

Parameters

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

Returns

A boolean value.

charCount

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 int
The code point to test.

Returns

An int value of 2 or 1.

toCodePoint

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 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

The decoded code point.

codePointAt

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 CharSequence
The sequence of char units.
index int
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().

codePointAt

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 char[]
The sequence of char units.
index int
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().

codePointAt

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 char[]
The sequence of char units.
index int
The index into the seq to retrieve and convert.
limit int
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.

codePointBefore

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 CharSequence
The CharSequence to search.
index int
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().

codePointBefore

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 char[]
The char[] to search.
index int
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.

codePointBefore

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 char[]
The char[] to search.
index int
The index into the seq.
start int
Not documented.

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.

toChars

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 int
The Unicode code point to encode.
dst char[]
The char[] to copy the encoded value into.
dstIndex int
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.

toChars

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 int
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.

codePointCount

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 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

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.

codePointCount

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 char[]
The char[] 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

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.

offsetByCodePoints

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 CharSequence
The CharSequence to find the index within.
index int
The index to begin from, within the CharSequence.
codePointOffset int
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.

offsetByCodePoints

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 char[]
The char[] to find the index within.
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 index to begin from, within the char[].
codePointOffset int
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.

reverseBytes

public static char reverseBytes(char c)
Reverse the order of the first and second bytes in character

Parameters

c char
the character

Returns

the character with reordered bytes.

valueOf

public static Character valueOf(char i)
Returns the object instance of i

Parameters

i char
the primitive

Returns

object instance

isWhitespace

public static boolean isWhitespace(char c)
See #isWhitespace(int).

isSpace

public static boolean isSpace(char ch)

isSpaceChar

public static boolean isSpaceChar(char ch)

isWhitespace

public static 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 for an alternative.

toTitleCase

public static int toTitleCase(int codePoint)

toTitleCase

public static char toTitleCase(char c)

digit

public static int digit(int codePoint, int radix)

isLetterOrDigit

public static boolean isLetterOrDigit(char ch)

isLetterOrDigit

public static boolean isLetterOrDigit(int codePoint)

isLetter

public static boolean isLetter(char ch)

isLetter

public static boolean isLetter(int codePoint)

isIdentifierIgnorable

public static boolean isIdentifierIgnorable(char ch)

isIdentifierIgnorable

public static boolean isIdentifierIgnorable(int codePoint)

isDigit

public static boolean isDigit(int codePoint)

isLowerCase

public static boolean isLowerCase(int codePoint)

isUpperCase

public static boolean isUpperCase(int codePoint)

toLowerCase

public static int toLowerCase(int codePoint)

toUpperCase

public static int toUpperCase(int codePoint)

highSurrogate

public static char highSurrogate(int codePoint)

lowSurrogate

public static char lowSurrogate(int codePoint)

isSpaceChar

public static boolean isSpaceChar(int codePoint)
Whether the code point is a Unicode space separator, line separator or paragraph separator.

getDirectionality

public static byte getDirectionality(char ch)

getType

public static int getType(char c)

isBmpCodePoint

public static boolean isBmpCodePoint(int codePoint)

isSurrogate

public static boolean isSurrogate(char ch)

getType

public static int getType(int codePoint)

compareTo

public int compareTo(Character another)
Compares this object to the specified object to determine their relative order.

Parameters

another Character
the object to compare to this instance.

Returns

a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.

Throws

ClassCastException
if another cannot be converted into something comparable to this instance.

toString

public static String toString(char c)
A one-char string of c.

toString

public static String toString(int codePoint)
The string of the code point: one char, or a surrogate pair.

Throws

IllegalArgumentException
if it is not a valid code point

hashCode

public static int hashCode(char value)
The char itself, as the JDK hashes it.

compare

public static int compare(char x, char y)
x - y.

isISOControl

public static boolean isISOControl(char ch)
Whether the char is an ISO control character: U+0000 to U+001F or U+007F to U+009F.

isISOControl

public static boolean isISOControl(int codePoint)
Whether the code point is an ISO control character.

forDigit

public static char forDigit(int digit, int radix)
The char of digit in radix, a lower case letter from 10 on, or U+0000 when either is out of range.

getNumericValue

public static int getNumericValue(char ch)
The value of a digit, or of a Latin letter read as a digit of base 36, or -1.

getNumericValue

public static int getNumericValue(int codePoint)
The value of a digit, or of a Latin letter read as a digit of base 36, or -1.

isAlphabetic

public static boolean isAlphabetic(int codePoint)
Whether the code point is alphabetic. This runtime answers as for isLetter.

isDefined

public static boolean isDefined(char ch)
Whether the char has a category in this runtime’s classification.

isDefined

public static boolean isDefined(int codePoint)
Whether the code point has a category in this runtime’s classification. Above Latin-1 that classification is partial, so an assigned symbol it does not know answers false.

isIdeographic

public static boolean isIdeographic(int codePoint)

Whether the code point is a CJK ideograph.

The blocks whole, unassigned gaps included: which code points inside them are assigned moves with every Unicode release (JDK 8 and JDK 21 answer differently), and this runtime carries no per-version table.

isTitleCase

public static boolean isTitleCase(char ch)
Whether the char is a title case letter.

isTitleCase

public static boolean isTitleCase(int codePoint)
Whether the code point is a title case letter.

isMirrored

public static boolean isMirrored(char ch)
Whether the char is mirrored in right-to-left text: the ASCII brackets and the guillemets.

isMirrored

public static boolean isMirrored(int codePoint)
Whether the code point is mirrored in right-to-left text. This runtime knows the ASCII brackets and the guillemets.

isJavaLetter

public static boolean isJavaLetter(char ch)
Deprecated.
As isJavaIdentifierStart(char).

isJavaLetterOrDigit

public static boolean isJavaLetterOrDigit(char ch)
Deprecated.
As isJavaIdentifierPart(char).

isUnicodeIdentifierStart

public static boolean isUnicodeIdentifierStart(char ch)
Whether the char may start a Unicode identifier.

isUnicodeIdentifierStart

public static boolean isUnicodeIdentifierStart(int codePoint)
Whether the code point may start a Unicode identifier: a letter.

isUnicodeIdentifierPart

public static boolean isUnicodeIdentifierPart(char ch)
Whether the char may continue a Unicode identifier.

isUnicodeIdentifierPart

public static boolean isUnicodeIdentifierPart(int codePoint)
Whether the code point may continue a Unicode identifier: a letter, a digit, connecting punctuation or an ignorable character.