1.4K
ASCII acronym for American Standard Code for Information Interchange. It is a 7-bit character set contains 128 (0 to 127) characters. It represents the numerical value of a character. For example, the ASCII value of A is 65.
Let’s have a look , how to print ASCII value or code through a Java program.
Program to find ASCII Value of a character
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: " + castAscii);
}
}
What You get as Output , After running the program
The ASCII value of a is: 97
Happy Programming 🙂