Java — Character getNumericValue Method
The Java Character getNumericValue() method is used to get the integer value that a specified Unicode character represents. For example, the character ‘\u216C’ (the roman numeral fifty) will return an integer 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.
Note − Extreme Characters (Character.MAX_VALUE and Character.MIN_VALUE) hold no numeric values.
Syntax
Following is the syntax for Java Character getNumericValue() method
Parameters
ch − the character to be converted
codePoint − the Unicode code point to be converted
Return Value
This method returns the numeric value of the character, as a non-negative int value; -2 if the character has a numeric value that is not a non-negative integer; -1 if the character has no numeric value.
Example
The following example shows the usage of Java Character getNumericValue(char ch) method.
Output
Let us compile and run the above program, this will produce the following result −
Example
The following example shows the usage of Java Character getNumericValue(int codePoint) method.
Output
Let us compile and run the above program, this will produce the following result −
Example
In another example, we pass integers that are not in a code point format as arguments to this method.
Output
If we compile and run the program, the output is obtained as −
Example
Symbols are non-numeric values. Hence, when they are passed as arguments to the method, -1 is returned. Let us see the program below −
Output
The program above is to be compiled and run to obtain the output given as follows −
Character getnumericvalue java что это

lang.Character class wraps the value of a primitive data type – char to an object of datatype char and this object contains single field having the data type – char. This class provides no. of methods regarding character manipulations like convert them from lowercase to uppercase. Character class is based on Unicode Standards to provide character information.
Class Declaration:
Following methods of Character class are discussed here :
- charCount() :java.lang.charCount() method uses Unicode point to return the number of char values to represent the argument char values. A Unicode code point is used for character values in the range between U+0000 and U+10FFFF and for 16-bit char values that are code units of the UTF-16 encoding.
Syntax :
Java code explaining use of charCount(), charValue(), codePointat() methods
Class Character
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 15.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:
| Java release | Unicode version |
|---|---|
| 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 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 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).
- 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.
Character getnumericvalue java что это
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.
The Java SE 8 Platform uses character information from version 6.2 of the Unicode Standard, with two extensions. First, the Java SE 8 Platform allows an implementation of class Character to use the Japanese Era code point, U+32FF , from the first version of the Unicode Standard after 6.2 that assigns the code point. Second, in recognition of the fact that new currencies appear frequently, the Java SE 8 Platform allows an implementation of class Character to use the Currency Symbols block from version 10.0 of the Unicode Standard. Consequently, the behavior of fields and methods of class Character may vary across implementations of the Java SE 8 Platform when processing the aforementioned code points ( outside of version 6.2 ), except for the following methods that define Java identifiers: isJavaIdentifierStart(int) , isJavaIdentifierStart(char) , isJavaIdentifierPart(int) , and isJavaIdentifierPart(char) . Code points in Java identifiers must be drawn from version 6.2 of the Unicode Standard.
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 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 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).
- 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.