java.lang.Object | |
↳ | java.lang.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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MAX_CODE_POINT | The maximum value of a Unicode code point. | |||||||||
char | MAX_HIGH_SURROGATE | The maximum value of a Unicode high-surrogate code unit in the UTF-16 encoding. | |||||||||
char | MAX_LOW_SURROGATE | The maximum value of a Unicode low-surrogate code unit in the UTF-16 encoding. | |||||||||
int | MAX_RADIX | The maximum radix available for conversion to and from Strings. | |||||||||
char | MAX_SURROGATE | The maximum value of a Unicode surrogate code unit in the UTF-16 encoding. | |||||||||
char | MAX_VALUE | The constant value of this field is the largest value of type
char . |
|||||||||
int | MIN_CODE_POINT | The minimum value of a Unicode code point. | |||||||||
char | MIN_HIGH_SURROGATE | The minimum value of a Unicode high-surrogate code unit in the UTF-16 encoding. | |||||||||
char | MIN_LOW_SURROGATE | The minimum value of a Unicode low-surrogate code unit in the UTF-16 encoding. | |||||||||
int | MIN_RADIX | The minimum radix available for conversion to and from Strings. | |||||||||
int | MIN_SUPPLEMENTARY_CODE_POINT | The minimum value of a supplementary code point. | |||||||||
char | MIN_SURROGATE | The minimum value of a Unicode surrogate code unit in the UTF-16 encoding. | |||||||||
char | MIN_VALUE | The constant value of this field is the smallest value of type
char . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Character(char value)
Constructs a
Character object and initializes it so that it
represents the primitive value argument. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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(CharSequence seq, int index)
Returns the code point preceding the given index of the
CharSequence . | ||||||||||
static int |
digit(char ch, int radix)
Returns the numeric value of the character
ch in the specified
radix. | ||||||||||
boolean |
equals(Object obj)
Compares this object against the specified object.
| ||||||||||
int |
hashCode()
Returns a hash code for this Character.
| ||||||||||
static boolean |
isDigit(char ch)
Determines if the specified character is a digit.
| ||||||||||
static boolean |
isHighSurrogate(char ch)
Determines if the given
char value is a high-surrogate code unit
(also known as leading-surrogate code unit). | ||||||||||
static boolean |
isLowSurrogate(char ch)
Determines if the given
char value is a low-surrogate code unit
(also known as trailing-surrogate code unit). | ||||||||||
static boolean |
isLowerCase(char ch)
Determines if the specified character is a lowercase character.
| ||||||||||
static boolean |
isUpperCase(char ch)
Determines if the specified character is an uppercase character.
| ||||||||||
static boolean |
isValidCodePoint(int codePoint)
Determines whether the specified code point is a valid Unicode code point
value in the range of
0x0000 to 0x10FFFF inclusive. | ||||||||||
static int |
toCodePoint(char high, char low)
Converts the specified surrogate pair to its supplementary code point value.
| ||||||||||
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.
| ||||||||||
String |
toString()
Returns a String object representing this character's value.
| ||||||||||
static char |
toUpperCase(char ch)
Converts the character argument to uppercase; if the character has no
lowercase equivalent, the character itself is returned.
| ||||||||||
static Character | valueOf(char c) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
The maximum value of a Unicode code point.
The maximum value of a Unicode high-surrogate code unit in the UTF-16 encoding. A high-surrogate is also known as a leading-surrogate.
The maximum value of a Unicode low-surrogate code unit in the UTF-16 encoding. A low-surrogate is also known as a trailing-surrogate.
The maximum radix available for conversion to and from Strings.
The maximum value of a Unicode surrogate code unit in the UTF-16 encoding.
The constant value of this field is the largest value of type
char
.
The minimum value of a Unicode code point.
The minimum value of a Unicode high-surrogate code unit in the UTF-16 encoding. A high-surrogate is also known as a leading-surrogate.
The minimum value of a Unicode low-surrogate code unit in the UTF-16 encoding. A low-surrogate is also known as a trailing-surrogate.
The minimum radix available for conversion to and from Strings.
The minimum value of a supplementary code point.
The minimum value of a Unicode surrogate code unit in the UTF-16 encoding.
The constant value of this field is the smallest value of type
char
.
Constructs a Character
object and initializes it so that it
represents the primitive value
argument.
value | value for the new Character object.
|
---|
Returns the value of this Character object.
char
value represented by this object.
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.
a | the char array |
---|---|
index | the index to the char values (Unicode code units) in
the char array to be converted |
NullPointerException | if a is null. |
---|---|
IndexOutOfBoundsException | if the value index is negative or not less than
the length of the char array. |
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.
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 |
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. |
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.
seq | a sequence of char values (Unicode code units) |
---|---|
index | the index to the char values (Unicode code units) in
seq to be converted |
NullPointerException | if seq is null. |
---|---|
IndexOutOfBoundsException | if the value index is negative or not less than
seq.length() . |
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.
a | the char array |
---|---|
index | the index following the code point that should be returned |
NullPointerException | if a is null. |
---|---|
IndexOutOfBoundsException | if the index argument is less than 1 or greater
than the length of the char array |
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.
seq | the CharSequence instance |
---|---|
index | the index following the code point that should be returned |
NullPointerException | if seq is null. |
---|---|
IndexOutOfBoundsException | if the index argument is less than 1 or greater
than seq.length() . |
Returns the numeric value of the character ch
in the specified
radix.
ch | the character to be converted. |
---|---|
radix | the radix. |
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.
obj | the object to compare with. |
---|
true
if the objects are the same; false
otherwise.
Returns a hash code for this Character.
Determines if the specified character is a digit.
ch | the character to be tested. |
---|
true
if the character is a digit; false
otherwise.Determines if the given char
value is a high-surrogate code unit
(also known as leading-surrogate code unit). Such values do not
represent characters by themselves, but are used in the representation of
supplementary characters in the UTF-16 encoding.
This method returns true
if and only if
isch >= '\uD800' && ch <= '\uDBFF'
true
.ch | the char value to be tested. |
---|
true
if the char
value is between
'\uD800' and '\uDBFF' inclusive; false
otherwise.isLowSurrogate(char)
Determines if the given char
value is a low-surrogate code unit
(also known as trailing-surrogate code unit). Such values do not
represent characters by themselves, but are used in the representation of
supplementary characters in the UTF-16 encoding.
This method returns true
if and only if
isch >= '\uDC00' && ch <= '\uDFFF'
true
.ch | the char value to be tested. |
---|
true
if the char
value is between
'\uDC00' and '\uDFFF' inclusive; false
otherwise.Determines if the specified character is a lowercase character.
ch | the character to be tested. |
---|
true
if the character is lowercase; false
otherwise.Determines if the specified character is an uppercase character.
ch | the character to be tested. |
---|
true
if the character is uppercase; false
otherwise.Determines whether the specified code point is a valid Unicode code point
value in the range of 0x0000
to 0x10FFFF
inclusive.
This method is equivalent to the expression:
codePoint >= 0x0000 && codePoint <= 0x10FFFF
codePoint | the Unicode code point to be tested |
---|
true
if the specified code point value is a valid code
point value; false
otherwise.Converts the specified surrogate pair to its supplementary code point value. This method does not validate the specified surrogate pair.
high | the high-surrogate code unit |
---|---|
low | the low-surrogate code unit |
The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.
ch | the character to be converted. |
---|
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.
Converts the character argument to uppercase; if the character has no lowercase equivalent, the character itself is returned.
ch | the character to be converted. |
---|