Way2Java

Java Character forDigit() Example

Many methods exist in java.lang.Character class used for different purposes. Some methods are useful for checking the character is a digit or letter or is a uppercase letter or lowercase letter etc. At the same time, some methods can modify the case of the letters from uppercase to lowercase or vice versa.

Now the present method is useful to know the radix number of a digit. Go on reading "Java Character forDigit() Example".

Following is the method signature as defined in java.lang.Character class.

Following example on Java Character forDigit() Example illustrates.
public class CharacterFunctionDemo
{
 public static void main(String args[])
 {
  System.out.println("9 representation in radix 10 format: " + Character.forDigit(9, 10));   // Octal radix format
  System.out.println("10 representation in radix 16 format: " + Character.forDigit(10, 16)); // Hexa radix format
 }
}



Output screenshot of CharacterFunctionDemo.java on Java Character forDigit() Example

You can try with other numbers and other radix formats in different combinations.