Class Character
- All Implemented Interfaces:
Comparable<Character>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe size of a char in bytes.static final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final intMaximum code point value -U+10FFFF.static final charMaximum value of a high surrogate or leading surrogate unit in UTF-16 encoding -'?'.static final charMaximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding -'?'.static final intThe maximum radix available for conversion to and from Strings.static final charMaximum value of a surrogate unit in UTF-16 encoding -'?'.static final charThe constant value of this field is the largest value of type char.static final intMinimum code point value -U+0000.static final charMinimum value of a high surrogate or leading surrogate unit in UTF-16 encoding -'?'.static final charMinimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding -'?'.static final intThe minimum radix available for conversion to and from Strings.static final intMinimum value of a supplementary code point -U+010000.static final charMinimum value of a surrogate unit in UTF-16 encoding -'?'.static final charThe constant value of this field is the smallest value of type char.static final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final intConstant for the number of bits to represent acharin two's compliment form.static final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionCharacter(char value) Constructs a Character object and initializes it so that it represents the primitive value argument. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcharCount(int codePoint) Calculates the number ofcharvalues required to represent the Unicode code point.charReturns the value of this Character object.static intcodePointAt(char[] seq, int index) Returns the code point at the index in thechar[].static intcodePointAt(char[] seq, int index, int limit) Returns the code point at the index in thechar[]that's within the limit.static intcodePointAt(CharSequence seq, int index) Returns the code point at the index in theCharSequence.static intcodePointBefore(char[] seq, int index) Returns the Unicode code point that proceeds theindexin thechar[].static intcodePointBefore(char[] seq, int index, int start) Returns the Unicode code point that proceeds theindexin thechar[]and isn't less thanstart.static intcodePointBefore(CharSequence seq, int index) Returns the Unicode code point that proceeds theindexin theCharSequence.static intcodePointCount(char[] seq, int offset, int count) Counts the number of Unicode code points in the subsequence of thechar[], as delineated by theoffsetandcount.static intcodePointCount(CharSequence seq, int beginIndex, int endIndex) Counts the number of Unicode code points in the subsequence of theCharSequence, as delineated by thebeginIndexandendIndex.static intcompare(char x, char y) x - y.intCompares this object to the specified object to determine their relative order.static intdigit(char ch, int radix) Returns the numeric value of the character ch in the specified radix.static intdigit(int codePoint, int radix) booleanCompares this object against the specified object.static charforDigit(int digit, int radix) The char ofdigitinradix, a lower case letter from 10 on, or U+0000 when either is out of range.static bytegetDirectionality(char ch) static intgetNumericValue(char ch) The value of a digit, or of a Latin letter read as a digit of base 36, or -1.static intgetNumericValue(int codePoint) The value of a digit, or of a Latin letter read as a digit of base 36, or -1.static intgetType(char c) static intgetType(int codePoint) inthashCode()Returns a hash code for this Character.static inthashCode(char value) The char itself, as the JDK hashes it.static charhighSurrogate(int codePoint) static booleanisAlphabetic(int codePoint) Whether the code point is alphabetic.static booleanisBmpCodePoint(int codePoint) static booleanisDefined(char ch) Whether the char has a category in this runtime's classification.static booleanisDefined(int codePoint) Whether the code point has a category in this runtime's classification.static booleanisDigit(char ch) Determines if the specified character is a digit.static booleanisDigit(int codePoint) static booleanisHighSurrogate(char ch) A test for determining if thecharis a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.static booleanisIdentifierIgnorable(char ch) static booleanisIdentifierIgnorable(int codePoint) static booleanisIdeographic(int codePoint) Whether the code point is a CJK ideograph.static booleanisISOControl(char ch) Whether the char is an ISO control character: U+0000 to U+001F or U+007F to U+009F.static booleanisISOControl(int codePoint) Whether the code point is an ISO control character.static booleanisJavaIdentifierPart(char ch) Determines whether the character can occur in a Java identifier.static booleanisJavaIdentifierPart(int codePoint) Determines whether the Unicode code point can occur in a Java identifier.static booleanisJavaIdentifierStart(char ch) Determines whether the character can start a Java identifier.static booleanisJavaIdentifierStart(int codePoint) Determines whether the Unicode code point can start a Java identifier.static booleanisJavaLetter(char ch) Deprecated.static booleanisJavaLetterOrDigit(char ch) Deprecated.static booleanisLetter(char ch) static booleanisLetter(int codePoint) static booleanisLetterOrDigit(char ch) static booleanisLetterOrDigit(int codePoint) static booleanisLowerCase(char ch) Determines if the specified character is a lowercase character.static booleanisLowerCase(int codePoint) static booleanisLowSurrogate(char ch) A test for determining if thecharis a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.static booleanisMirrored(char ch) Whether the char is mirrored in right-to-left text: the ASCII brackets and the guillemets.static booleanisMirrored(int codePoint) Whether the code point is mirrored in right-to-left text.static booleanisSpace(char ch) static booleanisSpaceChar(char ch) static booleanisSpaceChar(int codePoint) Whether the code point is a Unicode space separator, line separator or paragraph separator.static booleanisSupplementaryCodePoint(int codePoint) A test for determining if thecodePointis within the supplementary code point range.static booleanisSurrogate(char ch) static booleanisSurrogatePair(char high, char low) A test for determining if thecharpair is a valid surrogate pair.static booleanisTitleCase(char ch) Whether the char is a title case letter.static booleanisTitleCase(int codePoint) Whether the code point is a title case letter.static booleanisUnicodeIdentifierPart(char ch) Whether the char may continue a Unicode identifier.static booleanisUnicodeIdentifierPart(int codePoint) Whether the code point may continue a Unicode identifier: a letter, a digit, connecting punctuation or an ignorable character.static booleanisUnicodeIdentifierStart(char ch) Whether the char may start a Unicode identifier.static booleanisUnicodeIdentifierStart(int codePoint) Whether the code point may start a Unicode identifier: a letter.static booleanisUpperCase(char ch) Determines if the specified character is an uppercase character.static booleanisUpperCase(int codePoint) static booleanisValidCodePoint(int codePoint) A test for determining if thecodePointis a valid Unicode code point.static booleanisWhitespace(char c) See#isWhitespace(int).static booleanisWhitespace(int codePoint) Returns true if the given code point is a Unicode whitespace character.static charlowSurrogate(int codePoint) static intoffsetByCodePoints(char[] seq, int start, int count, int index, int codePointOffset) Determines the index into thechar[]that is offset (measured in code points and specified bycodePointOffset), from theindexargument and is within the subsequence as delineated bystartandcount.static intoffsetByCodePoints(CharSequence seq, int index, int codePointOffset) Determines the index into theCharSequencethat is offset (measured in code points and specified bycodePointOffset), from theindexargument.static charreverseBytes(char c) Reverse the order of the first and second bytes in characterstatic char[]toChars(int codePoint) Converts the Unicode code point,codePoint, into a UTF-16 encoded sequence that is returned as achar[].static inttoChars(int codePoint, char[] dst, int dstIndex) Converts the Unicode code point,codePoint, into a UTF-16 encoded sequence and copies the value(s) into thechar[]dst, starting at the indexdstIndex.static inttoCodePoint(char high, char low) Converts a surrogate pair into a Unicode code point.static chartoLowerCase(char ch) The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.static inttoLowerCase(int codePoint) toString()Returns a String object representing this character's value.static StringtoString(char c) A one-char string ofc.static StringtoString(int codePoint) The string of the code point: one char, or a surrogate pair.static chartoTitleCase(char c) static inttoTitleCase(int codePoint) static chartoUpperCase(char ch) Converts the character argument to uppercase; if the character has no uppercase equivalent, the character itself is returned.static inttoUpperCase(int codePoint) static CharactervalueOf(char i) Returns the object instance of i
-
Field Details
-
MAX_RADIX
public static final int MAX_RADIXThe maximum radix available for conversion to and from Strings. See Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values- See Also:
-
MAX_VALUE
public static final char MAX_VALUEThe constant value of this field is the largest value of type char. Since: JDK1.0.2 See Also:Constant Field Values- See Also:
-
MIN_RADIX
public static final int MIN_RADIXThe minimum radix available for conversion to and from Strings. See Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values- See Also:
-
MIN_VALUE
public static final char MIN_VALUEThe constant value of this field is the smallest value of type char. Since: JDK1.0.2 See Also:Constant Field Values- See Also:
-
MIN_HIGH_SURROGATE
public static final char MIN_HIGH_SURROGATEMinimum value of a high surrogate or leading surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MAX_HIGH_SURROGATE
public static final char MAX_HIGH_SURROGATEMaximum value of a high surrogate or leading surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MIN_LOW_SURROGATE
public static final char MIN_LOW_SURROGATEMinimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MAX_LOW_SURROGATE
public static final char MAX_LOW_SURROGATEMaximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MIN_SURROGATE
public static final char MIN_SURROGATEMinimum value of a surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MAX_SURROGATE
public static final char MAX_SURROGATEMaximum value of a surrogate unit in UTF-16 encoding -
'?'.Since
1.5
- See Also:
-
MIN_SUPPLEMENTARY_CODE_POINT
public static final int MIN_SUPPLEMENTARY_CODE_POINTMinimum value of a supplementary code point -
U+010000.Since
1.5
- See Also:
-
MIN_CODE_POINT
public static final int MIN_CODE_POINTMinimum code point value -
U+0000.Since
1.5
- See Also:
-
MAX_CODE_POINT
public static final int MAX_CODE_POINTMaximum code point value -
U+10FFFF.Since
1.5
- See Also:
-
SIZE
public static final int SIZEConstant for the number of bits to represent a
charin two's compliment form.Since
1.5
- See Also:
-
TYPE
-
UNASSIGNED
public static final byte UNASSIGNED- See Also:
-
UPPERCASE_LETTER
public static final byte UPPERCASE_LETTER- See Also:
-
LOWERCASE_LETTER
public static final byte LOWERCASE_LETTER- See Also:
-
TITLECASE_LETTER
public static final byte TITLECASE_LETTER- See Also:
-
MODIFIER_LETTER
public static final byte MODIFIER_LETTER- See Also:
-
OTHER_LETTER
public static final byte OTHER_LETTER- See Also:
-
NON_SPACING_MARK
public static final byte NON_SPACING_MARK- See Also:
-
ENCLOSING_MARK
public static final byte ENCLOSING_MARK- See Also:
-
COMBINING_SPACING_MARK
public static final byte COMBINING_SPACING_MARK- See Also:
-
DECIMAL_DIGIT_NUMBER
public static final byte DECIMAL_DIGIT_NUMBER- See Also:
-
LETTER_NUMBER
public static final byte LETTER_NUMBER- See Also:
-
OTHER_NUMBER
public static final byte OTHER_NUMBER- See Also:
-
SPACE_SEPARATOR
public static final byte SPACE_SEPARATOR- See Also:
-
LINE_SEPARATOR
public static final byte LINE_SEPARATOR- See Also:
-
PARAGRAPH_SEPARATOR
public static final byte PARAGRAPH_SEPARATOR- See Also:
-
CONTROL
public static final byte CONTROL- See Also:
-
FORMAT
public static final byte FORMAT- See Also:
-
PRIVATE_USE
public static final byte PRIVATE_USE- See Also:
-
SURROGATE
public static final byte SURROGATE- See Also:
-
DASH_PUNCTUATION
public static final byte DASH_PUNCTUATION- See Also:
-
START_PUNCTUATION
public static final byte START_PUNCTUATION- See Also:
-
END_PUNCTUATION
public static final byte END_PUNCTUATION- See Also:
-
CONNECTOR_PUNCTUATION
public static final byte CONNECTOR_PUNCTUATION- See Also:
-
OTHER_PUNCTUATION
public static final byte OTHER_PUNCTUATION- See Also:
-
MATH_SYMBOL
public static final byte MATH_SYMBOL- See Also:
-
CURRENCY_SYMBOL
public static final byte CURRENCY_SYMBOL- See Also:
-
MODIFIER_SYMBOL
public static final byte MODIFIER_SYMBOL- See Also:
-
OTHER_SYMBOL
public static final byte OTHER_SYMBOL- See Also:
-
INITIAL_QUOTE_PUNCTUATION
public static final byte INITIAL_QUOTE_PUNCTUATION- See Also:
-
FINAL_QUOTE_PUNCTUATION
public static final byte FINAL_QUOTE_PUNCTUATION- See Also:
-
DIRECTIONALITY_UNDEFINED
public static final byte DIRECTIONALITY_UNDEFINED- See Also:
-
DIRECTIONALITY_LEFT_TO_RIGHT
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT- See Also:
-
DIRECTIONALITY_RIGHT_TO_LEFT
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT- See Also:
-
DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC- See Also:
-
DIRECTIONALITY_EUROPEAN_NUMBER
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER- See Also:
-
DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR- See Also:
-
DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR- See Also:
-
DIRECTIONALITY_ARABIC_NUMBER
public static final byte DIRECTIONALITY_ARABIC_NUMBER- See Also:
-
DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR- See Also:
-
DIRECTIONALITY_NONSPACING_MARK
public static final byte DIRECTIONALITY_NONSPACING_MARK- See Also:
-
DIRECTIONALITY_BOUNDARY_NEUTRAL
public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL- See Also:
-
DIRECTIONALITY_PARAGRAPH_SEPARATOR
public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR- See Also:
-
DIRECTIONALITY_SEGMENT_SEPARATOR
public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR- See Also:
-
DIRECTIONALITY_WHITESPACE
public static final byte DIRECTIONALITY_WHITESPACE- See Also:
-
DIRECTIONALITY_OTHER_NEUTRALS
public static final byte DIRECTIONALITY_OTHER_NEUTRALS- See Also:
-
DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING- See Also:
-
DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE- See Also:
-
DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING- See Also:
-
DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE- See Also:
-
DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT- See Also:
-
BYTES
public static final int BYTESThe size of a char in bytes.- See Also:
-
-
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
-
hashCode
-
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- 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- 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- 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- 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
-
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
codePointis a valid Unicode code point.Parameters
codePoint: The code point to test.
Returns
A boolean value.
Since
1.5
-
isSupplementaryCodePoint
public static boolean isSupplementaryCodePoint(int codePoint) A test for determining if the
codePointis within the supplementary code point range.Parameters
codePoint: The code point to test.
Returns
A boolean value.
Since
1.5
-
isHighSurrogate
public static boolean isHighSurrogate(char ch) A test for determining if the
charis a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.Parameters
ch: Thecharunit to test.
Returns
A boolean value.
Since
1.5
See also
- #isLowSurrogate(char)
-
isLowSurrogate
public static boolean isLowSurrogate(char ch) A test for determining if the
charis a high surrogate/leading surrogate unit that's used for representing supplementary characters in UTF-16 encoding.Parameters
ch: Thecharunit to test.
Returns
A boolean value.
Since
1.5
See also
- #isHighSurrogate(char)
-
isSurrogatePair
public static boolean isSurrogatePair(char high, char low) A test for determining if the
charpair is a valid surrogate pair.Parameters
-
high: The high surrogate unit to test. -
low: The low surrogate unit to test.
Returns
A boolean value.
Since
1.5
See also
-
#isHighSurrogate(char)
-
#isLowSurrogate(char)
-
-
charCount
public static int charCount(int codePoint) Calculates the number of
charvalues required to represent the Unicode code point. This method only tests if thecodePointis greater than or equal to0x10000, in which case2is returned, otherwise1. To test if the code point is valid, use the#isValidCodePoint(int)method.Parameters
codePoint: The code point to test.
Returns
An
intvalue of 2 or 1.Since
1.5
See also
-
#isValidCodePoint(int)
-
#isSupplementaryCodePoint(int)
-
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: The high surrogate unit. -
low: The low surrogate unit.
Returns
The decoded code point.
Since
1.5
See also
- #isSurrogatePair(char, char)
-
-
codePointAt
Returns the code point at the index in the
CharSequence. Ifcharunit at the index is a high-surrogate unit, the next index is less than the length of the sequence and thecharunit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise thecharunit at the index is returned.Parameters
-
seq: The sequence ofcharunits. -
index: @param index The index into theseqto retrieve and convert.
Returns
The Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException if theindexis negative or greater than or equal toseq.length().
Since
1.5
-
-
codePointAt
public static int codePointAt(char[] seq, int index) Returns the code point at the index in the
char[]. Ifcharunit at the index is a high-surrogate unit, the next index is less than the length of the sequence and thecharunit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise thecharunit at the index is returned.Parameters
-
seq: The sequence ofcharunits. -
index: @param index The index into theseqto retrieve and convert.
Returns
The Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException if theindexis negative or greater than or equal toseq.length().
Since
1.5
-
-
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. Ifcharunit at the index is a high-surrogate unit, the next index is less than thelimitand thecharunit at the next index is a low surrogate unit, then the code point represented by the pair is returned; otherwise thecharunit at the index is returned.Parameters
-
seq: The sequence ofcharunits. -
index: @param index The index into theseqto retrieve and convert. -
limit: @param limit The exclusive index into theseqthat marks the end of the units that can be used.
Returns
The Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException if theindexis negative, greater than or equal tolimit,limitis negative orlimitis greater than the length ofseq.
Since
1.5
-
-
codePointBefore
Returns the Unicode code point that proceeds the
indexin theCharSequence. If thecharunit atindex - 1is within the low surrogate range, the valueindex - 2isn't negative and thecharunit atindex - 2is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, thecharvalue atindex - 1is returned.Parameters
-
seq: TheCharSequenceto search. -
index: The index into theseq.
Returns
A Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifindexis less than 1 or greater thanseq.length().
Since
1.5
-
-
codePointBefore
public static int codePointBefore(char[] seq, int index) Returns the Unicode code point that proceeds the
indexin thechar[]. If thecharunit atindex - 1is within the low surrogate range, the valueindex - 2isn't negative and thecharunit atindex - 2is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, thecharvalue atindex - 1is returned.Parameters
-
seq: Thechar[]to search. -
index: The index into theseq.
Returns
A Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifindexis less than 1 or greater thanseq.length.
Since
1.5
-
-
codePointBefore
public static int codePointBefore(char[] seq, int index, int start) Returns the Unicode code point that proceeds the
indexin thechar[]and isn't less thanstart. If thecharunit atindex - 1is within the low surrogate range, the valueindex - 2isn't less thanstartand thecharunit atindex - 2is within the high surrogate range, then the supplementary code point made up of the surrogate pair is returned; otherwise, thecharvalue atindex - 1is returned.Parameters
-
seq: Thechar[]to search. -
index: The index into theseq.
Returns
A Unicode code point.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifindexis less than or equal tostart,indexis greater thanseq.length,startis not negative andstartis greater thanseq.length.
Since
1.5
-
-
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 thechar[]dst, starting at the indexdstIndex.Parameters
-
codePoint: The Unicode code point to encode. -
dst: Thechar[]to copy the encoded value into. -
dstIndex: The index to start copying intodst.
Returns
- Returns:
The number of
charvalue units copied intodst.Throws
-
IllegalArgumentException: @throws IllegalArgumentException ifcodePointis not a valid Unicode code point. -
NullPointerException: ifdstisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifdstIndexis negative, greater than or equal todst.lengthor equalsdst.length - 1whencodePointis asupplementary code point.
Since
1.5
-
-
-
toChars
public static char[] toChars(int codePoint) Converts the Unicode code point,
codePoint, into a UTF-16 encoded sequence that is returned as achar[].Parameters
codePoint: The Unicode code point to encode.
Returns
- Returns:
The UTF-16 encoded
charsequence; if code point is asupplementary code point, then a 2chararray is returned, otherwise a 1chararray is returned.Throws
IllegalArgumentException: @throws IllegalArgumentException ifcodePointis not a valid Unicode code point.
Since
1.5
-
codePointCount
Counts the number of Unicode code points in the subsequence of the
CharSequence, as delineated by thebeginIndexandendIndex. Any surrogate values with missing pair values will be counted as 1 code point.Parameters
-
seq: TheCharSequenceto look through. -
beginIndex: The inclusive index to begin counting at. -
endIndex: The exclusive index to stop counting at.
Returns
The number of Unicode code points.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifbeginIndexis negative, greater thanseq.length()or greater thanendIndex.
Since
1.5
-
-
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 theoffsetandcount. Any surrogate values with missing pair values will be counted as 1 code point.Parameters
-
seq: Thechar[]to look through. -
offset: The inclusive index to begin counting at. -
count: @param count The number ofcharvalues to look through inseq.
Returns
The number of Unicode code points.
Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifoffsetorcountis negative or ifendIndexis greater thanseq.length.
Since
1.5
-
-
offsetByCodePoints
Determines the index into the
CharSequencethat is offset (measured in code points and specified bycodePointOffset), from theindexargument.Parameters
-
seq: TheCharSequenceto find the index within. -
index: @param index The index to begin from, within theCharSequence. -
codePointOffset: @param codePointOffset The number of code points to look back or forwards; may be a negative or positive value.
Returns
- Returns:
The calculated index that is
codePointOffsetcode points fromindex.Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifindexis negative, greater thanseq.length(), there aren't enough values inseqafterindexor beforeindexifcodePointOffsetis negative.
Since
1.5
-
-
-
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 bycodePointOffset), from theindexargument and is within the subsequence as delineated bystartandcount.Parameters
-
seq: Thechar[]to find the index within. -
index: The index to begin from, within thechar[]. -
codePointOffset: @param codePointOffset The number of code points to look back or forwards; may be a negative or positive value. -
start: @param start The inclusive index that marks the beginning of the subsequence. -
count: @param count The number ofcharvalues to include within the subsequence.
Returns
- Returns:
The calculated index that is
codePointOffsetcode points fromindex.Throws
-
NullPointerException: ifseqisnull. -
IndexOutOfBoundsException: @throws IndexOutOfBoundsException ifstartorcountis negative,start + countgreater thanseq.length,indexis less thanstart,indexis greater thanstart + countor there aren't enough values inseqafterindexor beforeindexifcodePointOffsetis negative.
Since
1.5
-
-
-
reverseBytes
public static char reverseBytes(char c) Reverse the order of the first and second bytes in character
Parameters
c: the character
Returns
the character with reordered bytes.
-
valueOf
Returns the object instance of i
Parameters
i: 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#isSpaceCharfor 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
Description copied from interface:ComparableCompares this object to the specified object to determine their relative order.
Parameters
another: the object to compare to this instance.
Returns
- Specified by:
compareToin interfaceComparable<Character>- Returns:
a negative integer if this instance is less than
another; a positive integer if this instance is greater thananother; 0 if this instance has the same order asanother.Throws
ClassCastException: @throws ClassCastException ifanothercannot be converted into something comparable tothisinstance.
-
toString
A one-char string ofc. -
toString
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 ofdigitinradix, 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 forisLetter. -
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
-
isJavaLetterOrDigit
Deprecated.AsisJavaIdentifierPart(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.
-