Java program to find the ASCII value of a character
ADVERTISEMENTS
Java program to find the ASCII value of a character. There are you will learn how to find the ASCII value of a character in the Java language.
Let us understand this example through the Java program:
// Java program to find the ASCII value of a character
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a character::\n");
char p = in.next().charAt(0);
int pAscii = p;
// Output
System.out.println("\nASCII value of " + p + " = " + pAscii);
}
}
Output:
Enter a character::
h
ASCII value of h = 104