1public class AsciiValue {
2
3 public static void main(String[] args) {
4
5 char ch = 'a';
6 int ascii = ch;
7 // You can also cast char to int
8 int castAscii = (int) ch;
9
10 System.out.println("The ASCII value of " + ch + " is: " + ascii);
11 System.out.println("The ASCII value of " + ch + " is: " + castAscii);
12 }
13}
1char character = name.charAt(0); // This gives the character 'a'
2int ascii = (int) character; // ascii is now 97.