We are going to share Java program to find ASCII value of a character with the output. If you are a Java beginner and want to start learning the Java programming, then keep your close attention in this tutorial as I am going to share how to write a Java program to find ASCII value of a character.
Copy the below Java program and execute it with the help of Javac compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public class AsciiValue { public static void main(String[] args) { char ch = 'a'; int ascii = ch; int castAscii = (int) ch; System.out.println("The ASCII value of " + ch + " is: " + ascii); System.out.println("The ASCII value of " + ch + " is: " + castAscii); } } |
The ASCII value of d is: 100
The ASCII value of d is: 100
Liked this program? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: ascii values in java, how to get ascii value of number in java, how to get ascii value of string in java, java program to find ascii value of a string, java program to print ascii values of alphabets, Java programs, Java programs with examples, Java programs with output, printing ascii in java