Module java.base
Package java.lang

# Class Character

≠
public final class Character
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<java.lang.Character>, java.lang.constant.Constable
Comparing jdk-master and valhalla-csr-open

All Implemented Interfaces:
  `Serializable, Comparable<Character>, Constable`

public final class Character extends Object implements Serializable, Comparable<Character>, Constable
The `Character` class is the wrapper class for values of the primitive type `char` . An object of type `Character` contains a single field whose type is `char` .

In addition, this class provides a large number of static methods for determining a character's category (lowercase letter, digit, etc.) and for converting characters from uppercase to lowercase and vice versa.

## Unicode Conformance

The fields and methods of class `Character` are defined in terms of character information from the Unicode Standard, specifically the UnicodeData file that is part of the Unicode Character Database. This file specifies properties including name and category for every assigned Unicode code point or character range. The file is available from the Unicode Consortium at http://www.unicode.org.

Character information is based on the Unicode Standard, version 17.0.

The Java platform has supported different versions of the Unicode Standard over time. Upgrades to newer versions of the Unicode Standard occurred in the following Java releases, each indicating the new version:

Shows Java releases and supported Unicode versions
Java release | Unicode version
--- | ---
Java SE 26 | Unicode 17.0
Java SE 24 | Unicode 16.0
Java SE 22 | Unicode 15.1
Java SE 20 | Unicode 15.0
Java SE 19 | Unicode 14.0
Java SE 15 | Unicode 13.0
Java SE 13 | Unicode 12.1
Java SE 12 | Unicode 11.0
Java SE 11 | Unicode 10.0
Java SE 9 | Unicode 8.0
Java SE 8 | Unicode 6.2
Java SE 7 | Unicode 6.0
Java SE 5.0 | Unicode 4.0
Java SE 1.4 | Unicode 3.0
JDK 1.1 | Unicode 2.0
JDK 1.0.2 | Unicode 1.1.5

Variations from these base Unicode versions, such as recognized appendixes, are documented elsewhere.

## Unicode Character Representations

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 point s is now U+0000 to U+10FFFF, known as Unicode scalar value .

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 character s. The Java 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:

- The methods that only accept a `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.
- The methods that accept an `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 Java SE 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.

This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail mutexes, or with object references.

When preview features are enabled, `Character` is a value classPREVIEW . Use of value class instances for synchronization, mutexes, or with object references result in `IdentityException` PREVIEW Moved out of a paragraph.Moved to a division with class preview-block.Moved to a division with class preview-comment..

Since:
  1.0
External Specifications
  - Unicode Character Database
See Also:
  - Serialized Form

## Nested Types

- = Subset
- = UnicodeBlock
- = UnicodeScript

## Fields

- =
  public static final int BYTES = 2
- =
  public static final byte COMBINING_SPACING_MARK = 8
- =
  public static final byte CONNECTOR_PUNCTUATION = 23
- =
  public static final byte CONTROL = 15
- =
  public static final byte CURRENCY_SYMBOL = 26
- =
  public static final byte DASH_PUNCTUATION = 20
- =
  public static final byte DECIMAL_DIGIT_NUMBER = 9
- =
  public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6
- =
  public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9
- =
  public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7
- =
  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3
- =
  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4
- =
  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5
- =
  public static final byte DIRECTIONALITY_FIRST_STRONG_ISOLATE = 21
- =
  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0
- =
  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14
- =
  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_ISOLATE = 19
- =
  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15
- =
  public static final byte DIRECTIONALITY_NONSPACING_MARK = 8
- =
  public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13
- =
  public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10
- =
  public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18
- =
  public static final byte DIRECTIONALITY_POP_DIRECTIONAL_ISOLATE = 22
- =
  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1
- =
  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2
- =
  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16
- =
  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ISOLATE = 20
- =
  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17
- =
  public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11
- =
  public static final byte DIRECTIONALITY_UNDEFINED = -1
- =
  public static final byte DIRECTIONALITY_WHITESPACE = 12
- =
  public static final byte ENCLOSING_MARK = 7
- =
  public static final byte END_PUNCTUATION = 22
- =
  public static final byte FINAL_QUOTE_PUNCTUATION = 30
- =
  public static final byte FORMAT = 16
- =
  public static final byte INITIAL_QUOTE_PUNCTUATION = 29
- =
  public static final byte LETTER_NUMBER = 10
- =
  public static final byte LINE_SEPARATOR = 13
- =
  public static final byte LOWERCASE_LETTER = 2
- =
  public static final byte MATH_SYMBOL = 25
- =
  public static final int MAX_CODE_POINT = 1114111
- =
  public static final char MAX_HIGH_SURROGATE = '\udbff'
- =
  public static final char MAX_LOW_SURROGATE = '\udfff'
- =
  public static final int MAX_RADIX = 36
- =
  public static final char MAX_SURROGATE = '\udfff'
- =
  public static final char MAX_VALUE = ''
- =
  public static final int MIN_CODE_POINT = 0
- =
  public static final char MIN_HIGH_SURROGATE = '\ud800'
- =
  public static final char MIN_LOW_SURROGATE = '\udc00'
- =
  public static final int MIN_RADIX = 2
- =
  public static final int MIN_SUPPLEMENTARY_CODE_POINT = 65536
- =
  public static final char MIN_SURROGATE = '\ud800'
- =
  public static final char MIN_VALUE = '\u0000'
- =
  public static final byte MODIFIER_LETTER = 4
- =
  public static final byte MODIFIER_SYMBOL = 27
- =
  public static final byte NON_SPACING_MARK = 6
- =
  public static final byte OTHER_LETTER = 5
- =
  public static final byte OTHER_NUMBER = 11
- =
  public static final byte OTHER_PUNCTUATION = 24
- =
  public static final byte OTHER_SYMBOL = 28
- =
  public static final byte PARAGRAPH_SEPARATOR = 14
- =
  public static final byte PRIVATE_USE = 18
- =
  public static final int SIZE = 16
- =
  public static final byte SPACE_SEPARATOR = 12
- =
  public static final byte START_PUNCTUATION = 21
- =
  public static final byte SURROGATE = 19
- =
  public static final byte TITLECASE_LETTER = 3
- =
  public static final java.lang.Class<java.lang.Character> TYPE
- =
  public static final byte UNASSIGNED = 0
- =
  public static final byte UPPERCASE_LETTER = 1

## Constructors

- =
  @Deprecated(since="9")
  public Character(char arg0)

## Methods

- =
  public static int charCount(int arg0)
- =
  public char charValue()
- =
  public static int codePointAt(char[] arg0, int arg1)
- =
  public static int codePointAt(char[] arg0, int arg1, int arg2)
- =
  public static int codePointAt(java.lang.CharSequence arg0, int arg1)
- =
  public static int codePointBefore(char[] arg0, int arg1)
- =
  public static int codePointBefore(char[] arg0, int arg1, int arg2)
- =
  public static int codePointBefore(java.lang.CharSequence arg0, int arg1)
- =
  public static int codePointCount(char[] arg0, int arg1, int arg2)
- =
  public static int codePointCount(java.lang.CharSequence arg0, int arg1, int arg2)
- =
  public static int codePointOf(java.lang.String arg0)
- =
  public static int compare(char arg0, char arg1)
- =
  public int compareTo(java.lang.Character arg0)
- =
  public java.util.Optional<java.lang.constant.DynamicConstantDesc<java.lang.Character>> describeConstable()
- =
  public static int digit(int arg0, int arg1)
- =
  public static int digit(char arg0, int arg1)
- =
  public boolean equals(java.lang.Object arg0)
- =
  public static char forDigit(int arg0, int arg1)
- =
  public static byte getDirectionality(int arg0)
- =
  public static byte getDirectionality(char arg0)
- =
  public static java.lang.String getName(int arg0)
- =
  public static int getNumericValue(int arg0)
- =
  public static int getNumericValue(char arg0)
- =
  public static int getType(int arg0)
- =
  public static int getType(char arg0)
- =
  public int hashCode()
- =
  public static int hashCode(char arg0)
- =
  public static char highSurrogate(int arg0)
- =
  public static boolean isAlphabetic(int arg0)
- =
  public static boolean isBmpCodePoint(int arg0)
- =
  public static boolean isDefined(int arg0)
- =
  public static boolean isDefined(char arg0)
- =
  public static boolean isDigit(int arg0)
- =
  public static boolean isDigit(char arg0)
- =
  public static boolean isEmoji(int arg0)
- =
  public static boolean isEmojiComponent(int arg0)
- =
  public static boolean isEmojiModifier(int arg0)
- =
  public static boolean isEmojiModifierBase(int arg0)
- =
  public static boolean isEmojiPresentation(int arg0)
- =
  public static boolean isExtendedPictographic(int arg0)
- =
  public static boolean isHighSurrogate(char arg0)
- =
  public static boolean isISOControl(int arg0)
- =
  public static boolean isISOControl(char arg0)
- =
  public static boolean isIdentifierIgnorable(int arg0)
- =
  public static boolean isIdentifierIgnorable(char arg0)
- =
  public static boolean isIdeographic(int arg0)
- =
  public static boolean isJavaIdentifierPart(int arg0)
- =
  public static boolean isJavaIdentifierPart(char arg0)
- =
  public static boolean isJavaIdentifierStart(int arg0)
- =
  public static boolean isJavaIdentifierStart(char arg0)
- =
  @Deprecated(since="1.1")
  public static boolean isJavaLetter(char arg0)
- =
  @Deprecated(since="1.1")
  public static boolean isJavaLetterOrDigit(char arg0)
- =
  public static boolean isLetter(int arg0)
- =
  public static boolean isLetter(char arg0)
- =
  public static boolean isLetterOrDigit(int arg0)
- =
  public static boolean isLetterOrDigit(char arg0)
- =
  public static boolean isLowSurrogate(char arg0)
- =
  public static boolean isLowerCase(int arg0)
- =
  public static boolean isLowerCase(char arg0)
- =
  public static boolean isMirrored(int arg0)
- =
  public static boolean isMirrored(char arg0)
- =
  @Deprecated(since="1.1")
  public static boolean isSpace(char arg0)
- =
  public static boolean isSpaceChar(int arg0)
- =
  public static boolean isSpaceChar(char arg0)
- =
  public static boolean isSupplementaryCodePoint(int arg0)
- =
  public static boolean isSurrogate(char arg0)
- =
  public static boolean isSurrogatePair(char arg0, char arg1)
- =
  public static boolean isTitleCase(int arg0)
- =
  public static boolean isTitleCase(char arg0)
- =
  public static boolean isUnicodeIdentifierPart(int arg0)
- =
  public static boolean isUnicodeIdentifierPart(char arg0)
- =
  public static boolean isUnicodeIdentifierStart(int arg0)
- =
  public static boolean isUnicodeIdentifierStart(char arg0)
- =
  public static boolean isUpperCase(int arg0)
- =
  public static boolean isUpperCase(char arg0)
- =
  public static boolean isValidCodePoint(int arg0)
- =
  public static boolean isWhitespace(int arg0)
- =
  public static boolean isWhitespace(char arg0)
- =
  public static char lowSurrogate(int arg0)
- =
  public static int offsetByCodePoints(char[] arg0, int arg1, int arg2, int arg3, int arg4)
- =
  public static int offsetByCodePoints(java.lang.CharSequence arg0, int arg1, int arg2)
- =
  public static char reverseBytes(char arg0)
- =
  public static char[] toChars(int arg0)
- =
  public static int toChars(int arg0, char[] arg1, int arg2)
- =
  public static int toCodePoint(char arg0, char arg1)
- =
  public static int toLowerCase(int arg0)
- =
  public static char toLowerCase(char arg0)
- =
  public java.lang.String toString()
- =
  public static java.lang.String toString(int arg0)
- =
  public static java.lang.String toString(char arg0)
- =
  public static int toTitleCase(int arg0)
- =
  public static char toTitleCase(char arg0)
- =
  public static int toUpperCase(int arg0)
- =
  public static char toUpperCase(char arg0)
- ≠
  public static java.lang.Character valueOf(char arg0)
  Comparing jdk-master and valhalla-csr-open

  ### valueOf

  public static Character valueOf (char c)
  Returns a `Character` instance representing the specified `char` value.

  - When preview features are NOT enabled, `Character` is an identity class. Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.If a new `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.Character` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph. instance is not required, this method should generally be used in preference to the constructor `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.Character(char)` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph., as this method is likely to yield significantly better space and time performance by caching frequently requested values. This method will always cache values in the range `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph. '\u0000'` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph. to `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.'\u007F'` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph., inclusive, and may cache other values outside of this range.

  - When preview features are enabled, `Character` is a value classPREVIEW . The `valueOf` behavior is the same as invoking the constructor, whether cached or not.

  Parameters:
    `c` - a char value.
  Returns:
    a `Character` instance representing `c` .
  Since:
    1.5

## Serialized Form

=

### serialVersionUID

=3786198910865385080

### Serialized Fields

- =
  char value

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
Character |  |  |  |  |  |  | 7 | 2 |  | 9
valueOf(char) |  |  |  |  |  |  | 6 | 5 |  | 11
Total |  |  |  |  |  |  | 13 | 7 |  | 20