GeezerVison is showing docs.oracle.com — Character (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang
Class Character
-
-
Nested Class Summary
Nested Classes
| Modifier and Type |
Class |
Description |
static class |
Character.Subset |
Instances of this class represent particular subsets of the Unicode
character set.
|
static class |
Character.UnicodeBlock |
A family of character subsets representing the character blocks in the
Unicode specification.
|
static class |
Character.UnicodeScript |
|
-
Constructor Summary
Constructors
| Constructor |
Description |
Character(char value) |
Constructs a newly allocated Character object that
represents the specified char value.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
static int |
charCount(int codePoint) |
Determines the number of char values needed to
represent the specified character (Unicode code point).
|
char |
charValue() |
Returns the value of this Character object.
|
static int |
codePointAt(char[] a,
int index) |
Returns the code point at the given index of the
char array.
|
static int |
codePointAt(char[] a,
int index,
int limit) |
Returns the code point at the given index of the
char array, where only array elements with
index less than limit can be used.
|
static int |
codePointAt(CharSequence seq,
int index) |
Returns the code point at the given index of the
CharSequence.
|
static int |
codePointBefore(char[] a,
int index) |
Returns the code point preceding the given index of the
char array.
|
static int |
codePointBefore(char[] a,
int index,
int start) |
Returns the code point preceding the given index of the
char array, where only array elements with
index greater than or equal to start
can be used.
|
static int |
codePointBefore(CharSequence seq,
int index) |
Returns the code point preceding the given index of the
CharSequence.
|
static int |
codePointCount(char[] a,
int offset,
int count) |
Returns the number of Unicode code points in a subarray of the
char array argument.
|
static int |
codePointCount(CharSequence seq,
int beginIndex,
int endIndex) |
Returns the number of Unicode code points in the text range of
the specified char sequence.
|
static int |
compare(char x,
char y) |
Compares two char values numerically.
|
int |
compareTo(Character anotherCharacter) |
Compares two Character objects numerically.
|
static int |
digit(char ch,
int radix) |
Returns the numeric value of the character ch in the
specified radix.
|
static int |
digit(int codePoint,
int radix) |
Returns the numeric value of the specified character (Unicode
code point) in the specified radix.
|
boolean |
equals(Object obj) |
Compares this object against the specified object.
|
static char |
forDigit(int digit,
int radix) |
Determines the character representation for a specific digit in
the specified radix.
|
static byte |
getDirectionality(char ch) |
Returns the Unicode directionality property for the given
character.
|
static byte |
getDirectionality(int codePoint) |
Returns the Unicode directionality property for the given
character (Unicode code point).
|
static String |
getName(int codePoint) |
Returns the Unicode name of the specified character
codePoint, or null if the code point is
unassigned.
|
static int |
getNumericValue(char ch) |
Returns the int value that the specified Unicode
character represents.
|
static int |
getNumericValue(int codePoint) |
Returns the int value that the specified
character (Unicode code point) represents.
|
static int |
getType(char ch) |
Returns a value indicating a character's general category.
|
static int |
getType(int codePoint) |
Returns a value indicating a character's general category.
|
int |
hashCode() |
Returns a hash code for this Character; equal to the result
of invoking charValue().
|
static int |
hashCode(char value) |
Returns a hash code for a char value; compatible with
Character.hashCode().
|
static char |
highSurrogate(int codePoint) |
|
static boolean |
isAlphabetic(int codePoint) |
Determines if the specified character (Unicode code point) is an alphabet.
|
static boolean |
isBmpCodePoint(int codePoint) |
|
static boolean |
isDefined(char ch) |
Determines if a character is defined in Unicode.
|
static boolean |
isDefined(int codePoint) |
Determines if a character (Unicode code point) is defined in Unicode.
|
static boolean |
isDigit(char ch) |
Determines if the specified character is a digit.
|
static boolean |
isDigit(int codePoint) |
Determines if the specified character (Unicode code point) is a digit.
|
static boolean |
isHighSurrogate(char ch) |
|
static boolean |
isIdentifierIgnorable(char ch) |
Determines if the specified character should be regarded as
an ignorable character in a Java identifier or a Unicode identifier.
|
static boolean |
isIdentifierIgnorable(int codePoint) |
Determines if the specified character (Unicode code point) should be regarded as
an ignorable character in a Java identifier or a Unicode identifier.
|
static boolean |
isIdeographic(int codePoint) |
Determines if the specified character (Unicode code point) is a CJKV
(Chinese, Japanese, Korean and Vietnamese) ideograph, as defined by
the Unicode Standard.
|
static boolean |
isISOControl(char ch) |
Determines if the specified character is an ISO control
character.
|
static boolean |
isISOControl(int codePoint) |
Determines if the referenced character (Unicode code point) is an ISO control
character.
|
static boolean |
isJavaIdentifierPart(char ch) |
Determines if the specified character may be part of a Java
identifier as other than the first character.
|
static boolean |
isJavaIdentifierPart(int codePoint) |
Determines if the character (Unicode code point) may be part of a Java
identifier as other than the first character.
|
static boolean |
isJavaIdentifierStart(char ch) |
Determines if the specified character is
permissible as the first character in a Java identifier.
|
static boolean |
isJavaIdentifierStart(int codePoint) |
Determines if the character (Unicode code point) is
permissible as the first character in a Java identifier.
|
static boolean |
isJavaLetter(char ch) |
Deprecated.
Replaced by isJavaIdentifierStart(char).
|
static boolean |
isJavaLetterOrDigit(char ch) |
Deprecated.
Replaced by isJavaIdentifierPart(char).
|
static boolean |
isLetter(char ch) |
Determines if the specified character is a letter.
|
static boolean |
isLetter(int codePoint) |
Determines if the specified character (Unicode code point) is a letter.
|
static boolean |
isLetterOrDigit(char ch) |
Determines if the specified character is a letter or digit.
|
static boolean |
isLetterOrDigit(int codePoint) |
Determines if the specified character (Unicode code point) is a letter or digit.
|
static boolean |
isLowerCase(char ch) |
Determines if the specified character is a lowercase character.
|
static boolean |
isLowerCase(int codePoint) |
Determines if the specified character (Unicode code point) is a
lowercase character.
|
static boolean |
isLowSurrogate(char ch) |
|
static boolean |
isMirrored(char ch) |
Determines whether the character is mirrored according to the
Unicode specification.
|
static boolean |
isMirrored(int codePoint) |
Determines whether the specified character (Unicode code point)
is mirrored according to the Unicode specification.
|
static boolean |
isSpace(char ch) |
Deprecated.
Replaced by isWhitespace(char).
|
static boolean |
isSpaceChar(char ch) |
Determines if the specified character is a Unicode space character.
|
static boolean |
isSpaceChar(int codePoint) |
Determines if the specified character (Unicode code point) is a
Unicode space character.
|
static boolean |
isSupplementaryCodePoint(int codePoint) |
|
static boolean |
isSurrogate(char ch) |
Determines if the given char value is a Unicode
surrogate code unit.
|
static boolean |
isSurrogatePair(char high,
char low) |
|
static boolean |
isTitleCase(char ch) |
Determines if the specified character is a titlecase character.
|
static boolean |
isTitleCase(int codePoint) |
Determines if the specified character (Unicode code point) is a titlecase character.
|
static boolean |
isUnicodeIdentifierPart(char ch) |
Determines if the specified character may be part of a Unicode
identifier as other than the first character.
|
static boolean |
isUnicodeIdentifierPart(int codePoint) |
Determines if the specified character (Unicode code point) may be part of a Unicode
identifier as other than the first character.
|
static boolean |
isUnicodeIdentifierStart(char ch) |
Determines if the specified character is permissible as the
first character in a Unicode identifier.
|
static boolean |
isUnicodeIdentifierStart(int codePoint) |
Determines if the specified character (Unicode code point) is permissible as the
first character in a Unicode identifier.
|
static boolean |
isUpperCase(char ch) |
Determines if the specified character is an uppercase character.
|
static boolean |
isUpperCase(int codePoint) |
Determines if the specified character (Unicode code point) is an uppercase character.
|
static boolean |
isValidCodePoint(int codePoint) |
|
static boolean |
isWhitespace(char ch) |
Determines if the specified character is white space according to Java.
|
static boolean |
isWhitespace(int codePoint) |
Determines if the specified character (Unicode code point) is
white space according to Java.
|
static char |
lowSurrogate(int codePoint) |
|
static int |
offsetByCodePoints(char[] a,
int start,
int count,
int index,
int codePointOffset) |
Returns the index within the given char subarray
that is offset from the given index by
codePointOffset code points.
|
static int |
offsetByCodePoints(CharSequence seq,
int index,
int codePointOffset) |
Returns the index within the given char sequence that is offset
from the given index by codePointOffset
code points.
|
static char |
reverseBytes(char ch) |
Returns the value obtained by reversing the order of the bytes in the
specified char value.
|
static char[] |
toChars(int codePoint) |
Converts the specified character (Unicode code point) to its
UTF-16 representation stored in a char array.
|
static int |
toChars(int codePoint,
char[] dst,
int dstIndex) |
Converts the specified character (Unicode code point) to its
UTF-16 representation.
|
static int |
toCodePoint(char high,
char low) |
Converts the specified surrogate pair to its supplementary code
point value.
|
static char |
toLowerCase(char ch) |
Converts the character argument to lowercase using case
mapping information from the UnicodeData file.
|
static int |
toLowerCase(int codePoint) |
Converts the character (Unicode code point) argument to
lowercase using case mapping information from the UnicodeData
file.
|
String |
toString() |
Returns a String object representing this
Character's value.
|
static String |
toString(char c) |
Returns a String object representing the
specified char.
|
static char |
toTitleCase(char ch) |
Converts the character argument to titlecase using case mapping
information from the UnicodeData file.
|
static int |
toTitleCase(int codePoint) |
Converts the character (Unicode code point) argument to titlecase using case mapping
information from the UnicodeData file.
|
static char |
toUpperCase(char ch) |
Converts the character argument to uppercase using case mapping
information from the UnicodeData file.
|
static int |
toUpperCase(int codePoint) |
Converts the character (Unicode code point) argument to
uppercase using case mapping information from the UnicodeData
file.
|
static Character |
valueOf(char c) |
Returns a Character instance representing the specified
char value.
|
-
-
Field Detail
-
MIN_VALUE
public static final char MIN_VALUE
The constant value of this field is the smallest value of type
char, '\u0000'.
- Since:
- 1.0.2
- See Also:
- Constant Field Values
-
MAX_VALUE
public static final char MAX_VALUE
The constant value of this field is the largest value of type
char, '\uFFFF'.
- Since:
- 1.0.2
- See Also:
- Constant Field Values
-
MIN_SURROGATE
public static final char MIN_SURROGATE
The minimum value of a Unicode surrogate code unit in the
UTF-16 encoding, constant '\uD800'.
- Since:
- 1.5
- See Also:
- Constant Field Values
-
MAX_SURROGATE
public static final char MAX_SURROGATE
The maximum value of a Unicode surrogate code unit in the
UTF-16 encoding, constant '\uDFFF'.
- Since:
- 1.5
- See Also:
- Constant Field Values
-
SIZE
public static final int SIZE
The number of bits used to represent a char value in unsigned
binary form, constant 16.
- Since:
- 1.5
- See Also:
- Constant Field Values
-
Method Detail
-
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.
- Overrides:
equals in class Object
- Parameters:
obj - the object to compare with.
- Returns:
true if the objects are the same;
false otherwise.
- See Also:
Object.hashCode(),
HashMap
-
codePointAt
public static int codePointAt(CharSequence seq,
int index)
Returns the code point at the given index of the
CharSequence. If the char value at
the given index in the CharSequence is in the
high-surrogate range, the following index is less than the
length of the CharSequence, and the
char value at the following index is in the
low-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at the given index is returned.
- Parameters:
seq - a sequence of char values (Unicode code
units)
index - the index to the char values (Unicode
code units) in seq to be converted
- Returns:
- the Unicode code point at the given index
- Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the value
index is negative or not less than
seq.length().
- Since:
- 1.5
-
codePointAt
public static int codePointAt(char[] a,
int index)
Returns the code point at the given index of the
char array. If the char value at
the given index in the char array is in the
high-surrogate range, the following index is less than the
length of the char array, and the
char value at the following index is in the
low-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at the given index is returned.
- Parameters:
a - the char array
index - the index to the char values (Unicode
code units) in the char array to be converted
- Returns:
- the Unicode code point at the given index
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if the value
index is negative or not less than
the length of the char array.
- Since:
- 1.5
-
codePointAt
public static int codePointAt(char[] a,
int index,
int limit)
Returns the code point at the given index of the
char array, where only array elements with
index less than limit can be used. If
the char value at the given index in the
char array is in the high-surrogate range, the
following index is less than the limit, and the
char value at the following index is in the
low-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at the given index is returned.
- Parameters:
a - the char array
index - the index to the char values (Unicode
code units) in the char array to be converted
limit - the index after the last array element that
can be used in the char array
- Returns:
- the Unicode code point at the given index
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if the index
argument is negative or not less than the limit
argument, or if the limit argument is negative or
greater than the length of the char array.
- Since:
- 1.5
-
codePointBefore
public static int codePointBefore(CharSequence seq,
int index)
Returns the code point preceding the given index of the
CharSequence. If the char value at
(index - 1) in the CharSequence is in
the low-surrogate range, (index - 2) is not
negative, and the char value at (index - 2)
in the CharSequence is in the
high-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at (index - 1) is
returned.
- Parameters:
seq - the CharSequence instance
index - the index following the code point that should be returned
- Returns:
- the Unicode code point value before the given index.
- Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the index
argument is less than 1 or greater than seq.length().
- Since:
- 1.5
-
codePointBefore
public static int codePointBefore(char[] a,
int index)
Returns the code point preceding the given index of the
char array. If the char value at
(index - 1) in the char array is in
the low-surrogate range, (index - 2) is not
negative, and the char value at (index - 2)
in the char array is in the
high-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at (index - 1) is
returned.
- Parameters:
a - the char array
index - the index following the code point that should be returned
- Returns:
- the Unicode code point value before the given index.
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if the index
argument is less than 1 or greater than the length of the
char array
- Since:
- 1.5
-
codePointBefore
public static int codePointBefore(char[] a,
int index,
int start)
Returns the code point preceding the given index of the
char array, where only array elements with
index greater than or equal to start
can be used. If the char value at (index - 1)
in the char array is in the
low-surrogate range, (index - 2) is not less than
start, and the char value at
(index - 2) in the char array is in
the high-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char value at (index - 1) is
returned.
- Parameters:
a - the char array
index - the index following the code point that should be returned
start - the index of the first array element in the
char array
- Returns:
- the Unicode code point value before the given index.
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if the index
argument is not greater than the start argument or
is greater than the length of the char array, or
if the start argument is negative or not less than
the length of the char array.
- Since:
- 1.5
-
toChars
public static int toChars(int codePoint,
char[] dst,
int dstIndex)
Converts the specified character (Unicode code point) to its
UTF-16 representation. If the specified code point is a BMP
(Basic Multilingual Plane or Plane 0) value, the same value is
stored in dst[dstIndex], and 1 is returned. If the
specified code point is a supplementary character, its
surrogate values are stored in dst[dstIndex]
(high-surrogate) and dst[dstIndex+1]
(low-surrogate), and 2 is returned.
- Parameters:
codePoint - the character (Unicode code point) to be converted.
dst - an array of char in which the
codePoint's UTF-16 value is stored.
dstIndex - the start index into the dst
array where the converted value is stored.
- Returns:
- 1 if the code point is a BMP code point, 2 if the
code point is a supplementary code point.
- Throws:
IllegalArgumentException - if the specified
codePoint is not a valid Unicode code point.
NullPointerException - if the specified dst is null.
IndexOutOfBoundsException - if dstIndex
is negative or not less than dst.length, or if
dst at dstIndex doesn't have enough
array element(s) to store the resulting char
value(s). (If dstIndex is equal to
dst.length-1 and the specified
codePoint is a supplementary character, the
high-surrogate value is not stored in
dst[dstIndex].)
- Since:
- 1.5
-
toChars
public static char[] toChars(int codePoint)
Converts the specified character (Unicode code point) to its
UTF-16 representation stored in a char array. If
the specified code point is a BMP (Basic Multilingual Plane or
Plane 0) value, the resulting char array has
the same value as codePoint. If the specified code
point is a supplementary code point, the resulting
char array has the corresponding surrogate pair.
- Parameters:
codePoint - a Unicode code point
- Returns:
- a
char array having
codePoint's UTF-16 representation.
- Throws:
IllegalArgumentException - if the specified
codePoint is not a valid Unicode code point.
- Since:
- 1.5
-
codePointCount
public static int codePointCount(CharSequence seq,
int beginIndex,
int endIndex)
Returns the number of Unicode code points in the text range of
the specified char sequence. The text range begins at the
specified beginIndex and extends to the
char at index endIndex - 1. Thus the
length (in chars) of the text range is
endIndex-beginIndex. Unpaired surrogates within
the text range count as one code point each.
- Parameters:
seq - the char sequence
beginIndex - the index to the first char of
the text range.
endIndex - the index after the last char of
the text range.
- Returns:
- the number of Unicode code points in the specified text
range
- Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the
beginIndex is negative, or endIndex
is larger than the length of the given sequence, or
beginIndex is larger than endIndex.
- Since:
- 1.5
-
codePointCount
public static int codePointCount(char[] a,
int offset,
int count)
Returns the number of Unicode code points in a subarray of the
char array argument. The offset
argument is the index of the first char of the
subarray and the count argument specifies the
length of the subarray in chars. Unpaired
surrogates within the subarray count as one code point each.
- Parameters:
a - the char array
offset - the index of the first char in the
given char array
count - the length of the subarray in chars
- Returns:
- the number of Unicode code points in the specified subarray
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if offset or
count is negative, or if offset +
count is larger than the length of the given array.
- Since:
- 1.5
-
offsetByCodePoints
public static int offsetByCodePoints(CharSequence seq,
int index,
int codePointOffset)
Returns the index within the given char sequence that is offset
from the given index by codePointOffset
code points. Unpaired surrogates within the text range given by
index and codePointOffset count as
one code point each.
- Parameters:
seq - the char sequence
index - the index to be offset
codePointOffset - the offset in code points
- Returns:
- the index within the char sequence
- Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if index
is negative or larger then the length of the char sequence,
or if codePointOffset is positive and the
subsequence starting with index has fewer than
codePointOffset code points, or if
codePointOffset is negative and the subsequence
before index has fewer than the absolute value
of codePointOffset code points.
- Since:
- 1.5
-
offsetByCodePoints
public static int offsetByCodePoints(char[] a,
int start,
int count,
int index,
int codePointOffset)
Returns the index within the given char subarray
that is offset from the given index by
codePointOffset code points. The
start and count arguments specify a
subarray of the char array. Unpaired surrogates
within the text range given by index and
codePointOffset count as one code point each.
- Parameters:
a - the char array
start - the index of the first char of the
subarray
count - the length of the subarray in chars
index - the index to be offset
codePointOffset - the offset in code points
- Returns:
- the index within the subarray
- Throws:
NullPointerException - if a is null.
IndexOutOfBoundsException - if start or count is negative,
or if start + count is larger than the length of
the given array,
or if index is less than start or
larger then start + count,
or if codePointOffset is positive and the text range
starting with index and ending with start + count - 1
has fewer than codePointOffset code
points,
or if codePointOffset is negative and the text range
starting with start and ending with index - 1
has fewer than the absolute value of
codePointOffset code points.
- Since:
- 1.5
-
isIdeographic
public static boolean isIdeographic(int codePoint)
Determines if the specified character (Unicode code point) is a CJKV
(Chinese, Japanese, Korean and Vietnamese) ideograph, as defined by
the Unicode Standard.
- Parameters:
codePoint - the character (Unicode code point) to be tested.
- Returns:
true if the character is a Unicode ideograph
character, false otherwise.
- Since:
- 1.7
-
isISOControl
public static boolean isISOControl(int codePoint)
Determines if the referenced character (Unicode code point) is an ISO control
character. A character is considered to be an ISO control
character if its code is in the range '\u0000'
through '\u001F' or in the range
'\u007F' through '\u009F'.
- Parameters:
codePoint - the character (Unicode code point) to be tested.
- Returns:
true if the character is an ISO control character;
false otherwise.
- Since:
- 1.5
- See Also:
isSpaceChar(int),
isWhitespace(int)
-
isMirrored
public static boolean isMirrored(int codePoint)
Determines whether the specified character (Unicode code point)
is mirrored according to the Unicode specification. Mirrored
characters should have their glyphs horizontally mirrored when
displayed in text that is right-to-left. For example,
'\u0028' LEFT PARENTHESIS is semantically
defined to be an opening parenthesis. This will appear
as a "(" in text that is left-to-right but as a ")" in text
that is right-to-left.
- Parameters:
codePoint - the character (Unicode code point) to be tested.
- Returns:
true if the character is mirrored, false
if the character is not mirrored or is not defined.
- Since:
- 1.5
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|