In this program, you will learn how to determine the ASCII value of a character. In this example, we are taking variable ch to store character ‘n’ and ascii to store the equivalent ASCII value of the character.
Program To Print The Ascii Value Of A Given Character
public class Ascii
{
public static void main(String[] args)
{
char ch = ‘n’;
int ascii = ch;
System.out.println(“The ASCII value of character ” + ch + ” is: ” + ascii);
}
}
Output:
The ASCII value of character n is: 110
in the above example, we checked the ASCII value of character n and the output of the program is 110 that is equivalent ASCII value of n