Tuesday, August 11, 2020

Write a Program to Find ASCII Value of a character in Java.

Find ASCII Value of a character in Java.

 Find ASCII Value of a character in Java.

Find and display the ASCII value of a character in Java. This is done using type-casting and normal variable assignment operations.

EXAMPLE :-

public class Ascii {

public static void main(String[] args) {

char ch1 = 'S';
int asciiValue = ch1;
int castAsciiValue = (int) ch1;

System.out.println("The ASCII Value of " + ch1 + " is : " + asciiValue);
System.out.println("The ASCII Value of " + ch1 + " is : " + castAsciiValue);
}
}

OUTPUT

The ASCII Value of M is : 77 The ASCII Value of M is : 77

No comments:

Post a Comment

Please do not any spam link in Comment Box