char ch = '9'; int num = Character.getNumericValue(ch); System.out.println("Numeric value of " + ch + " is " + num);
char ch = 'A'; int num = Character.getNumericValue(ch); System.out.println("Numeric value of " + ch + " is " + num);Output: Numeric value of A is -1 In the second example, since the character 'A' is not a numeric digit, the method returns -1. This method is part of the java.lang package library, which means it is available by default and doesn't require any additional libraries.