public final class Character extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CODE_POINT
Maximum code point value -
U+10FFFF. |
static char |
MAX_HIGH_SURROGATE
Maximum value of a high surrogate or leading surrogate unit in UTF-16
encoding -
'?'. |
static char |
MAX_LOW_SURROGATE
Maximum value of a low surrogate or trailing surrogate unit in UTF-16
encoding -
'?'. |
static int |
MAX_RADIX
The maximum radix available for conversion to and from Strings.
|
static char |
MAX_SURROGATE
Maximum value of a surrogate unit in UTF-16 encoding -
'?'. |
static char |
MAX_VALUE
The constant value of this field is the largest value of type char.
|
static int |
MIN_CODE_POINT
Minimum code point value -
U+0000. |
static char |
MIN_HIGH_SURROGATE
Minimum value of a high surrogate or leading surrogate unit in UTF-16
encoding -
'?'. |
static char |
MIN_LOW_SURROGATE
Minimum value of a low surrogate or trailing surrogate unit in UTF-16
encoding -
'?'. |
static int |
MIN_RADIX
The minimum radix available for conversion to and from Strings.
|
static int |
MIN_SUPPLEMENTARY_CODE_POINT
Minimum value of a supplementary code point -
U+010000. |
static char |
MIN_SURROGATE
Minimum value of a surrogate unit in UTF-16 encoding -
'?'. |
static char |
MIN_VALUE
The constant value of this field is the smallest value of type char.
|
static int |
SIZE
Constant for the number of bits to represent a
char in
two's compliment form. |
| Constructor and Description |
|---|
Character(char value)
Constructs a Character object and initializes it so that it represents the primitive value argument.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
charCount(int codePoint)
Calculates the number of
char values required to represent
the Unicode code point. |
char |
charValue()
Returns the value of this Character object.
|
static int |
codePointAt(char[] seq,
int index)
Returns the code point at the index in the
char[]. |
static int |
codePointAt(char[] seq,
int index,
int limit)
Returns the code point at the index in the
char[] that's
within the limit. |
static int |
codePointAt(CharSequence seq,
int index)
Returns the code point at the index in the
CharSequence. |
static int |
codePointBefore(char[] seq,
int index)
Returns the Unicode code point that proceeds the
index in
the char[]. |
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. |
static int |
codePointBefore(CharSequence seq,
int index)
Returns the Unicode code point that proceeds the
index in
the CharSequence. |
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. |
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. |
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)
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. |
static boolean |
isLowerCase(char ch)
Determines if the specified character is a lowercase character.
|
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. |
static boolean |
isSpace(char ch) |
static boolean |
isSpaceChar(char ch) |
static boolean |
isSupplementaryCodePoint(int codePoint)
A test for determining if the
codePoint is within the
supplementary code point range. |
static boolean |
isSurrogatePair(char high,
char low)
A test for determining if the
char pair is a valid
surrogate pair. |
static boolean |
isUpperCase(char ch)
Determines if the specified character is an uppercase character.
|
static boolean |
isValidCodePoint(int codePoint)
A test for determining if the
codePoint is a valid Unicode
code point. |
static boolean |
isWhitespace(char c)
See
isWhitespace(int). |
static boolean |
isWhitespace(int codePoint)
Returns true if the given code point is a Unicode whitespace character.
|
static 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. |
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. |
static char |
reverseBytes(char c)
Reverse the order of the first and second bytes in character
|
static char[] |
toChars(int codePoint)
Converts the Unicode code point,
codePoint, into a UTF-16
encoded sequence that is returned as a char[]. |
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. |
static int |
toCodePoint(char high,
char low)
Converts a surrogate pair into a Unicode code point.
|
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 |
toTitleCase(char c) |
static int |
toTitleCase(int codePoint) |
static char |
toUpperCase(char ch)
Converts the character argument to uppercase; if the character has no uppercase equivalent, the character itself is returned.
|
static Character |
valueOf(char i)
Returns the object instance of i
|
public static final int MAX_RADIX
public static final char MAX_VALUE
public static final int MIN_RADIX
public static final char MIN_VALUE
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
'?'.
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
Minimum value of a supplementary code point - U+010000.
public static final int MIN_CODE_POINT
Minimum code point value - U+0000.
public static final int MAX_CODE_POINT
Maximum code point value - U+10FFFF.
public static final int SIZE
Constant for the number of bits to represent a char in
two's compliment form.
public Character(char value)
public char charValue()
public static int digit(char ch,
int radix)
public boolean equals(Object obj)
public int hashCode()
public static boolean isDigit(char ch)
public static boolean isLowerCase(char ch)
public static boolean isUpperCase(char ch)
public static char toLowerCase(char ch)
public String toString()
public static char toUpperCase(char ch)
public static boolean isValidCodePoint(int codePoint)
A test for determining if the codePoint is a valid Unicode
code point.
codePoint - The code point to test.public static boolean isSupplementaryCodePoint(int codePoint)
A test for determining if the codePoint is within the
supplementary code point range.
codePoint - The code point to test.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.
ch - The char unit to test.isLowSurrogate(char)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.
ch - The char unit to test.isHighSurrogate(char)public static boolean isSurrogatePair(char high,
char low)
A test for determining if the char pair is a valid
surrogate pair.
high - The high surrogate unit to test.low - The low surrogate unit to test.isHighSurrogate(char),
isLowSurrogate(char)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.
codePoint - The code point to test.int value of 2 or 1.isValidCodePoint(int),
isSupplementaryCodePoint(int)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
isSurrogatePair(char, char) method should be used prior to this
method to validate the pair.
high - The high surrogate unit.low - The low surrogate unit.isSurrogatePair(char, char)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.
seq - The sequence of char units.index - The index into the seq to retrieve and
convert.NullPointerException - if seq is null.IndexOutOfBoundsException - if the index is negative
or greater than or equal to seq.length().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.
seq - The sequence of char units.index - The index into the seq to retrieve and
convert.NullPointerException - if seq is null.IndexOutOfBoundsException - if the index is negative
or greater than or equal to seq.length().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.
seq - The sequence of char units.index - The index into the seq to retrieve and
convert.limit - The exclusive index into the seq that marks
the end of the units that can be used.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.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.
seq - The CharSequence to search.index - The index into the seq.NullPointerException - if seq is null.IndexOutOfBoundsException - if index is less than 1
or greater than seq.length().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.
seq - The char[] to search.index - The index into the seq.NullPointerException - if seq is null.IndexOutOfBoundsException - if index is less than 1
or greater than seq.length.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.
seq - The char[] to search.index - The index into the seq.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.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.
codePoint - The Unicode code point to encode.dst - The char[] to copy the encoded value into.dstIndex - The index to start copying into dst.char value units copied into
dst.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.public static char[] toChars(int codePoint)
Converts the Unicode code point, codePoint, into a UTF-16
encoded sequence that is returned as a char[].
codePoint - The Unicode code point to encode.char sequence; if code point is
a supplementary code point,
then a 2 char array is returned, otherwise a 1
char array is returned.IllegalArgumentException - if codePoint is not a
valid Unicode code point.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.
seq - The CharSequence to look through.beginIndex - The inclusive index to begin counting at.endIndex - The exclusive index to stop counting at.NullPointerException - if seq is null.IndexOutOfBoundsException - if beginIndex is
negative, greater than seq.length() or greater
than 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. Any surrogate values with missing pair values will
be counted as 1 code point.
seq - The char[] to look through.offset - The inclusive index to begin counting at.count - The number of char values to look through in
seq.NullPointerException - if seq is null.IndexOutOfBoundsException - if offset or
count is negative or if endIndex is
greater than seq.length.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.
seq - The CharSequence to find the index within.index - The index to begin from, within the
CharSequence.codePointOffset - The number of code points to look back or
forwards; may be a negative or positive value.codePointOffset code
points from index.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.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.
seq - The char[] to find the index within.index - The index to begin from, within the char[].codePointOffset - The number of code points to look back or
forwards; may be a negative or positive value.start - The inclusive index that marks the beginning of the
subsequence.count - The number of char values to include within
the subsequence.codePointOffset code
points from index.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.public static char reverseBytes(char c)
c - the characterpublic static Character valueOf(char i)
i - the primitivepublic static boolean isWhitespace(char c)
isWhitespace(int).public static boolean isSpace(char ch)
public static boolean isSpaceChar(char ch)
public static boolean isWhitespace(int codePoint)
isSpaceChar(char)
for an alternative.public static int toTitleCase(int codePoint)
public static char toTitleCase(char c)