Java Character getNumericValue() MethodThe getNumericValue() method of character class returns the int value of the specified character. If the character does not have any int value, -1 is returned. If the character has a numeric value that cannot be represented as a non-negative integer, -2 is returned. SyntaxParameterThe above method requires only one parameter: The codePoint is the character(Unicode code point) to be converted. Return ValueThe getNumericValue(int codePoint) method returns the numeric value of the character, as a non-negative int value. This method will return -2 if the character has a numeric value but the value cannot be represented as a non-negative int value. The method will return -1 if the character has no numeric value.. Example 1Output: The character 'n' has a numeric value represented as: 23 Example 2Output: Numeric value for code point obj1 is 33 Numeric value for code point obj2 is -1 Example 3Output: The character 'n' has a numeric value represented as: 23 The character ' ' has a numeric value represented as: -1 The character '6' has a numeric value represented as: 6 Next TopicJava-character-gettype-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India