In this Example, We will Introduced you about the getNumericValue() method of the character class.
Example For getNumericValue() method in java
In this Example, We will Introduced you about the getNumericValue() method of the character class. This method returns the numeric value of the character. If any character don't have any numeric value than it returns -1 and returns -2 if the value is not represented as a non negative.
This method have parameter as the character to be find the numeric value as- getNumericValue('ch')
Example: GetNumericValue.java
package com.devmanuals; public class GetNumericValue { public static void main(String[] args) { System.out.print("The Numeric value of A is= "); System.out.println(Character.getNumericValue('A')); System.out.print("The Numeric value of B is= "); System.out.println(Character.getNumericValue('B')); System.out.print("The Numeric value of G is= "); System.out.println(Character.getNumericValue('G')); } }
Output:
The Numeric value of A is= 10 The Numeric value of B is= 11 The Numeric value of G is= 16 |
[ 0 ] Comments