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 a character's category (lowercase letter, digit, etc.) and for converting characters from uppercase to lowercase and vice versa.
Character information is based on the Unicode Standard, version 4.0.
The methods and data of class Character
are defined by
the information in the UnicodeData file that is part of the
Unicode Character Database maintained by the Unicode
Consortium. This file specifies various properties including name
and general category for every defined Unicode code point or
character range.
The file and its description are available from the Unicode Consortium at:
The char
data type (and therefore the value that a
Character
object encapsulates) are based on the
original Unicode specification, which defined characters as
fixed-width 16-bit entities. The Unicode standard has since been
changed to allow for characters whose representation requires more
than 16 bits. The range of legal code points is now
U+0000 to U+10FFFF, known as Unicode scalar value.
(Refer to the
definition of the U+n notation in the Unicode
standard.)
The set of characters from U+0000 to U+FFFF is sometimes
referred to as the Basic Multilingual Plane (BMP). Characters whose code points are greater
than U+FFFF are called supplementary characters. The Java
2 platform uses the UTF-16 representation in char
arrays and in the String
and StringBuffer
classes. In this representation, supplementary characters are
represented as a pair of char
values, the first from
the high-surrogates range, (\uD800-\uDBFF), the
second from the low-surrogates range
(\uDC00-\uDFFF).
A char
value, therefore, represents Basic
Multilingual Plane (BMP) code points, including the surrogate
code points, or code units of the UTF-16 encoding. An
int
value represents all Unicode code points,
including supplementary code points. The lower (least significant)
21 bits of int
are used to represent Unicode code
points and the upper (most significant) 11 bits must be zero.
Unless otherwise specified, the behavior with respect to
supplementary characters and surrogate char
values is
as follows:
char
value cannot support
supplementary characters. They treat char
values from the
surrogate ranges as undefined characters. For example,
Character.isLetter('\uD840')
returns false
, even though
this specific value if followed by any low-surrogate value in a string
would represent a letter.
int
value support all
Unicode characters, including supplementary characters. For
example, Character.isLetter(0x2F81A)
returns
true
because the code point value represents a letter
(a CJK ideograph).
In the J2SE API documentation, Unicode code point is
used for character values in the range between U+0000 and U+10FFFF,
and Unicode code unit is used for 16-bit
char
values that are code units of the UTF-16
encoding. For more information on Unicode terminology, refer to the
Unicode Glossary.
Character
object that
represents the specified char
value.char
values have undefined directionality in the Unicode specification.digit
method, the forDigit
method, and the toString
method of class
Integer
.char
, '\uFFFF'
.digit
method, the forDigit
method, and the toString
method of class
Integer
.char
, '\u0000'
.Class
instance representing the primitive type
char
.char
values needed to
represent the specified character (Unicode code point). If the
specified character is equal to or greater than 0x10000, then
the method returns 2. Otherwise, the method returns 1.
This method doesn't validate the specified character to be a valid Unicode code point. The caller must validate the character value using isValidCodePoint if necessary.
Character
object.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.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.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.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.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.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.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 char
s. Unpaired
surrogates within the subarray count as one code point each.beginIndex
and extends to the
char
at index endIndex - 1
. Thus the
length (in char
s) of the text range is
endIndex-beginIndex
. Unpaired surrogates within
the text range count as one code point each.Character
objects numerically.In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive. The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."
ch
in the
specified radix.
If the radix is not in the range MIN_RADIX
<=
radix
<= MAX_RADIX
or if the
value of ch
is not a valid digit in the specified
radix, -1
is returned. A character is a valid digit
if at least one of the following is true:
isDigit
is true
of the character
and the Unicode decimal digit value of the character (or its
single-character decomposition) is less than the specified radix.
In this case the decimal digit value is returned.
'A'
through 'Z'
and its code is less than
radix + 'A' - 10
.
In this case, ch - 'A' + 10
is returned.
'a'
through 'z'
and its code is less than
radix + 'a' - 10
.
In this case, ch - 'a' + 10
is returned.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
If the radix is not in the range MIN_RADIX
<=
radix
<= MAX_RADIX
or if the
character is not a valid digit in the specified
radix, -1
is returned. A character is a valid digit
if at least one of the following is true:
true
of the character
and the Unicode decimal digit value of the character (or its
single-character decomposition) is less than the specified radix.
In this case the decimal digit value is returned.
'A'
through 'Z'
and its code is less than
radix + 'A' - 10
.
In this case, ch - 'A' + 10
is returned.
'a'
through 'z'
and its code is less than
radix + 'a' - 10
.
In this case, ch - 'a' + 10
is returned.
true
if and only if the argument is not
null
and is a Character
object that
represents the same char
value as this object.radix
is not a
valid radix, or the value of digit
is not a valid
digit in the specified radix, the null character
('\u0000'
) is returned.
The radix
argument is valid if it is greater than or
equal to MIN_RADIX
and less than or equal to
MAX_RADIX
. The digit
argument is valid if
0 <=digit < radix
.
If the digit is less than 10, then
'0' + digit
is returned. Otherwise, the value
'a' + digit - 10
is returned.
char
values is DIRECTIONALITY_UNDEFINED
.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
int
value that the specified Unicode
character represents. For example, the character
'\u216C'
(the roman numeral fifty) will return
an int with a value of 50.
The letters A-Z in their uppercase ('\u0041'
through
'\u005A'
), lowercase
('\u0061'
through '\u007A'
), and
full width variant ('\uFF21'
through
'\uFF3A'
and '\uFF41'
through
'\uFF5A'
) forms have numeric values from 10
through 35. This is independent of the Unicode specification,
which does not assign numeric values to these char
values.
If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
int
value that the specified
character (Unicode code point) represents. For example, the character
'\u216C'
(the Roman numeral fifty) will return
an int
with a value of 50.
The letters A-Z in their uppercase ('\u0041'
through
'\u005A'
), lowercase
('\u0061'
through '\u007A'
), and
full width variant ('\uFF21'
through
'\uFF3A'
and '\uFF41'
through
'\uFF5A'
) forms have numeric values from 10
through 35. This is independent of the Unicode specification,
which does not assign numeric values to these char
values.
If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
Character
.A character is defined if at least one of the following is true:
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is defined if at least one of the following is true:
A character is a digit if its general category type, provided
by Character.getType(ch)
, is
DECIMAL_DIGIT_NUMBER
.
Some Unicode character ranges that contain digits:
'\u0030'
through '\u0039'
,
ISO-LATIN-1 digits ('0'
through '9'
)
'\u0660'
through '\u0669'
,
Arabic-Indic digits
'\u06F0'
through '\u06F9'
,
Extended Arabic-Indic digits
'\u0966'
through '\u096F'
,
Devanagari digits
'\uFF10'
through '\uFF19'
,
Fullwidth digits
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is a digit if its general category type, provided
by getType(codePoint)
, is
DECIMAL_DIGIT_NUMBER
.
Some Unicode character ranges that contain digits:
'\u0030'
through '\u0039'
,
ISO-LATIN-1 digits ('0'
through '9'
)
'\u0660'
through '\u0669'
,
Arabic-Indic digits
'\u06F0'
through '\u06F9'
,
Extended Arabic-Indic digits
'\u0966'
through '\u096F'
,
Devanagari digits
'\uFF10'
through '\uFF19'
,
Fullwidth digits
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
.The following Unicode characters are ignorable in a Java identifier or a Unicode identifier:
'\u0000'
through '\u0008'
'\u000E'
through '\u001B'
'\u007F'
through '\u009F'
FORMAT
general
category value
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
The following Unicode characters are ignorable in a Java identifier or a Unicode identifier:
'\u0000'
through '\u0008'
'\u000E'
through '\u001B'
'\u007F'
through '\u009F'
FORMAT
general
category value
'\u0000'
through '\u001F'
or in the range
'\u007F'
through '\u009F'
.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
'\u0000'
through '\u001F'
or in the range
'\u007F'
through '\u009F'
.A character may be part of a Java identifier if any of the following are true:
'$'
)
'_'
)
isIdentifierIgnorable
returns
true
for the character
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character may be part of a Java identifier if any of the following are true:
'$'
)
'_'
)
true
for
the character
A character may start a Java identifier if and only if one of the following conditions is true:
true
LETTER_NUMBER
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character may start a Java identifier if and only if one of the following conditions is true:
true
LETTER_NUMBER
A character may start a Java identifier if and only if one of the following is true:
true
LETTER_NUMBER
A character may be part of a Java identifier if and only if any of the following are true:
'$'
)
'_'
)
isIdentifierIgnorable
returns
true
for the character.
A character is considered to be a letter if its general
category type, provided by Character.getType(ch)
,
is any of the following:
UPPERCASE_LETTER
LOWERCASE_LETTER
TITLECASE_LETTER
MODIFIER_LETTER
OTHER_LETTER
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is considered to be a letter if its general category type, provided by getType(codePoint) , is any of the following:
UPPERCASE_LETTER
LOWERCASE_LETTER
TITLECASE_LETTER
MODIFIER_LETTER
OTHER_LETTER
A character is considered to be a letter or digit if either
Character.isLetter(char ch)
or
Character.isDigit(char ch)
returns
true
for the character.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is considered to be a letter or digit if either
isLetter(codePoint)
or
isDigit(codePoint)
returns
true
for the character.
A character is lowercase if its general category type, provided
by Character.getType(ch)
, is
LOWERCASE_LETTER
.
The following are examples of lowercase characters:
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'
Many other Unicode characters are lowercase too.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is lowercase if its general category type, provided
by
, is
LOWERCASE_LETTER
.
The following are examples of lowercase characters:
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'
Many other Unicode characters are lowercase too.
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
.'\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.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
'\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.true
for the following five
characters only:
'\t' | '\u0009' |
HORIZONTAL TABULATION |
'\n' | '\u000A' |
NEW LINE |
'\f' | '\u000C' |
FORM FEED |
'\r' | '\u000D' |
CARRIAGE RETURN |
' ' | '\u0020' |
SPACE |
SPACE_SEPARATOR
LINE_SEPARATOR
PARAGRAPH_SEPARATOR
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
codePoint >= 0x10000 && codePoint <= 0x10ffff
char
values is a valid surrogate pair. This method is equivalent to
the expression:
isHighSurrogate(high) && isLowSurrogate(low)
A character is a titlecase character if its general
category type, provided by Character.getType(ch)
,
is TITLECASE_LETTER
.
Some characters look like pairs of Latin letters. For example, there is an uppercase letter that looks like "LJ" and has a corresponding lowercase letter that looks like "lj". A third form, which looks like "Lj", is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.
These are some of the Unicode characters for which this method returns
true
:
LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
LATIN CAPITAL LETTER L WITH SMALL LETTER J
LATIN CAPITAL LETTER N WITH SMALL LETTER J
LATIN CAPITAL LETTER D WITH SMALL LETTER Z
Many other Unicode characters are titlecase too.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is a titlecase character if its general
category type, provided by getType(codePoint)
,
is TITLECASE_LETTER
.
Some characters look like pairs of Latin letters. For example, there is an uppercase letter that looks like "LJ" and has a corresponding lowercase letter that looks like "lj". A third form, which looks like "Lj", is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.
These are some of the Unicode characters for which this method returns
true
:
LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
LATIN CAPITAL LETTER L WITH SMALL LETTER J
LATIN CAPITAL LETTER N WITH SMALL LETTER J
LATIN CAPITAL LETTER D WITH SMALL LETTER Z
Many other Unicode characters are titlecase too.
A character may be part of a Unicode identifier if and only if one of the following statements is true:
'_'
)
isIdentifierIgnorable
returns
true
for this character.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character may be part of a Unicode identifier if and only if one of the following statements is true:
'_'
)
isIdentifierIgnorable
returns
true
for this character.
A character may start a Unicode identifier if and only if one of the following conditions is true:
true
LETTER_NUMBER
.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character may start a Unicode identifier if and only if one of the following conditions is true:
true
LETTER_NUMBER
.
A character is uppercase if its general category type, provided by
Character.getType(ch)
, is UPPERCASE_LETTER
.
The following are examples of uppercase characters:
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'
Many other Unicode characters are uppercase too.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
A character is uppercase if its general category type, provided by
getType(codePoint)
, is UPPERCASE_LETTER
.
The following are examples of uppercase characters:
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'
Many other Unicode characters are uppercase too.
0x0000
to
0x10FFFF
inclusive. This method is equivalent to
the expression:
codePoint >= 0x0000 && codePoint <= 0x10FFFF
SPACE_SEPARATOR
,
LINE_SEPARATOR
, or PARAGRAPH_SEPARATOR
)
but is not also a non-breaking space ('\u00A0'
,
'\u2007'
, '\u202F'
).
'\u0009'
, HORIZONTAL TABULATION.
'\u000A'
, LINE FEED.
'\u000B'
, VERTICAL TABULATION.
'\u000C'
, FORM FEED.
'\u000D'
, CARRIAGE RETURN.
'\u001C'
, FILE SEPARATOR.
'\u001D'
, GROUP SEPARATOR.
'\u001E'
, RECORD SEPARATOR.
'\u001F'
, UNIT SEPARATOR.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
'\u00A0'
,
'\u2007'
, '\u202F'
).
'\u0009'
, HORIZONTAL TABULATION.
'\u000A'
, LINE FEED.
'\u000B'
, VERTICAL TABULATION.
'\u000C'
, FORM FEED.
'\u000D'
, CARRIAGE RETURN.
'\u001C'
, FILE SEPARATOR.
'\u001D'
, GROUP SEPARATOR.
'\u001E'
, RECORD SEPARATOR.
'\u001F'
, UNIT SEPARATOR.
wait
methods.
The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized
statement
that synchronizes on the object.
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
wait
methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
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.index
by codePointOffset
code points. Unpaired surrogates within the text range given by
index
and codePointOffset
count as
one code point each.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.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.
Note that
Character.isLowerCase(Character.toLowerCase(ch))
does not always return true
for some ranges of
characters, particularly those that are symbols or ideographs.
In general,
should be used to map
characters to lowercase. String
case mapping methods
have several benefits over Character
case mapping methods.
String
case mapping methods can perform locale-sensitive
mappings, context-sensitive mappings, and 1:M character mappings, whereas
the Character
case mapping methods cannot.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
Note that
Character.isLowerCase(Character.toLowerCase(codePoint))
does not always return true
for some ranges of
characters, particularly those that are symbols or ideographs.
In general,
should be used to map
characters to lowercase. String
case mapping methods
have several benefits over Character
case mapping methods.
String
case mapping methods can perform locale-sensitive
mappings, context-sensitive mappings, and 1:M character mappings, whereas
the Character
case mapping methods cannot.
String
object representing this
Character
's value. The result is a string of
length 1 whose sole component is the primitive
char
value represented by this
Character
object.String
object representing the
specified char
. The result is a string of length
1 consisting solely of the specified char
.char
argument is already a titlecase
char
, the same char
value will be
returned.
Note that
Character.isTitleCase(Character.toTitleCase(ch))
does not always return true
for some ranges of
characters.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
Note that
Character.isTitleCase(Character.toTitleCase(codePoint))
does not always return true
for some ranges of
characters.
Note that
Character.isUpperCase(Character.toUpperCase(ch))
does not always return true
for some ranges of
characters, particularly those that are symbols or ideographs.
In general,
should be used to map
characters to uppercase. String
case mapping methods
have several benefits over Character
case mapping methods.
String
case mapping methods can perform locale-sensitive
mappings, context-sensitive mappings, and 1:M character mappings, whereas
the Character
case mapping methods cannot.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method.
Note that
Character.isUpperCase(Character.toUpperCase(codePoint))
does not always return true
for some ranges of
characters, particularly those that are symbols or ideographs.
In general,
should be used to map
characters to uppercase. String
case mapping methods
have several benefits over Character
case mapping methods.
String
case mapping methods can perform locale-sensitive
mappings, context-sensitive mappings, and 1:M character mappings, whereas
the Character
case mapping methods cannot.
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.The current thread must own this object's monitor.
This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).
If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.
Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:
notify
method
or the notifyAll
method.
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout, nanos); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.