Find ASCII Value of Character Java
PROGRAM TO FIND ASCII VALUE OF CHARACTER
public class Main {
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);
}
}
OUTPUT
The ASCII value of a is: 97 The ASCII value of a is: 97
Comments
Post a Comment