Write a Java Program to Find ASCII Value of a character

Write a Java Program to Find ASCII Value of a character

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class AsciiValue {

    public static void main(String[] args) {

        char ch = 'a';
        int ascii = ch;
        // You can also cast char to int
        int castAscii = (int) ch;

        System.out.println("The ASCII value of " + ch + " is: " + ascii);
        System.out.println("The ASCII value of " + ch + " is: " + castAscii);
    }
}

 

Final Output

1 thought on “Write a Java Program to Find ASCII Value of a character”

Leave a Comment