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: " + ascii);
System.out.println("The ASCII value of " + ch + " is: " + castAscii);
}
}
When you run the program, the output will be:
The ASCII value of a is: 97 The ASCII value of a is: 97
Comments
Post a Comment
For More Codes Comment In The Box