Online Java Compiler By
JavaTpoint.com
import java.util.Scanner; public class JavaCharacterDigitExample1 { public static void main(String[] args) { // Ask the user for the input System.out.print("Enter the input of your choice:"); // Use scanner to get the user input Scanner s = new Scanner(System.in); char[] value = s.nextLine().toCharArray(); // ask for radix input System.out.print("Enter the radix:"); // get the radix int radix = s.nextInt(); // close the scanner object s.close(); for (char charval : value) { int digit = Character.digit(charval, radix); // print the result System.out.println("The numeric value of the character is returned"+" as: " + digit); } } }
Output