Java Data Type Tutorial - Java Character.digit(int codePoint, int radix)








Syntax

Character.digit(int codePoint, int radix) has the following syntax.

public static int digit(int codePoint, int radix)

Example

In the following code shows how to use Character.digit(int codePoint, int radix) method.

public class Main {
//from  w  w w .  j  a va2 s  .co m
   public static void main(String[] args) {
      int ch1 = 9;
      int ch2 = 3;

      int i1 = Character.digit(ch1, 2);
      int i2 = Character.digit(ch2, 10);

      System.out.println("Numeric value of " + ch1 + " in radix 2 is " + i1);
      System.out.println("Numeric value of " + ch2 + " in radix 10 is " + i2);

   }
}

The code above generates the following result.