Java Program to Find ASCII Value

In this example, we are giving a program to find ASCII value of a character.


To find ASCII value:

  1. # To find ascii value
  2. public class AsciiValue {
  3. public static void main(String[] args) {
  4. char ch = 'a';
  5. int ascii = ch;
  6. System.out.println("The ASCII value of " + ch + " is: " + ascii);
  7. }
  8. }

Output:

The ASCII value of a is: 97