write a program in java to accept a word and print the ASCII code
Answers
Answered by
2
Answer:
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);
}
}
Explanation:
output will be:
The ASCII value of a is: 97
The ASCII value of a is: 97
Similar questions