filmov
tv
Java Program to Find ASCII Value of a character | #shorts #java #program
Показать описание
JAVA PROGRAM FOR BEGINNERS:
ASCII stands for the "American Standard Code for Information Interchange".
It was designed in the early 60's, as a standard character set for computers and electronic devices.
ASCII is a 7-bit character set containing 128 characters.
It contains the numbers from 0-9, the upper and lower case English letters from A to Z, and some special characters.
The character sets used in modern computers, in HTML, and on the Internet, are all based on ASCII.
The following tables list the 128 ASCII characters and their equivalent number.
In this program, you'll learn to find and display the ASCII value of a character in Java. This is done using type-casting and normal variable assignment operations.
To understand this example, you should have the knowledge of the following Java programming topics:
Java Program to Find ASCII Value of a character:
In the above program, character is stored in a char variable, ch. Like, double quotes (" ") are used to declare strings, we use single quotes (' ') to declare characters.
Now, to find the ASCII value of ch, we just assign ch to an int variable ascii. Internally, Java converts the character value to an ASCII value.
We can also cast the character ch to an integer using (int). In simple terms, casting is converting variable from one type to another, here char variable ch is converted to an int variable castAscii.
Finally, we print the ascii value using the println() function.
ASCII stands for the "American Standard Code for Information Interchange".
It was designed in the early 60's, as a standard character set for computers and electronic devices.
ASCII is a 7-bit character set containing 128 characters.
It contains the numbers from 0-9, the upper and lower case English letters from A to Z, and some special characters.
The character sets used in modern computers, in HTML, and on the Internet, are all based on ASCII.
The following tables list the 128 ASCII characters and their equivalent number.
In this program, you'll learn to find and display the ASCII value of a character in Java. This is done using type-casting and normal variable assignment operations.
To understand this example, you should have the knowledge of the following Java programming topics:
Java Program to Find ASCII Value of a character:
In the above program, character is stored in a char variable, ch. Like, double quotes (" ") are used to declare strings, we use single quotes (' ') to declare characters.
Now, to find the ASCII value of ch, we just assign ch to an int variable ascii. Internally, Java converts the character value to an ASCII value.
We can also cast the character ch to an integer using (int). In simple terms, casting is converting variable from one type to another, here char variable ch is converted to an int variable castAscii.
Finally, we print the ascii value using the println() function.