class GetAscii
{
public static void main(String arg[])
{
char c='p';
int i=c;
System.out.println("Ascii value of character " + c + " is " + i);
}
}
To get the ascii value of a character, store the character in an integer variable. in the above program. Variable c is assigned with the value 'p'. When it is assigned to the integer variable say i, the ascii value of the variable get stored in i.
Save the program as GetAscii.java
No comments :
Post a Comment