Understanding ASCII and How to Print ASCII Values in Java

ASCII is a character encoding standard: It is used to represent text in computers and other devices. Each of its characters is assigned a unique numerical value comprising, amongst others, letters, digits, punctuation and control. For example, the ASCII value of the letter 'A' is 65, and of the letter 'a' is 97.

In this blog post I will explain a simple Java program that outputs the ASCII values for lower case letters deathnbsp;'a' to 'z'; this helps you understand how characters are actually represented by the computer as well as work with ASCII values in Java.

What is ASCII

ASCII is a 7-bit character encoding standard that can represent 128 characters (0 to 127). These characters include:

Uppercase letters: A to Z (ASCII values 65 to 90)

Lowercase letters: a to z (ASCII values 97 to 122)

Digits: 0 to 9 (ASCII values 48 to 57)

Special characters: !, @, #, $, etc.

Control characters: Newline (\n), tab (\t), etc.

Subsequently, when writing programs for programming matrix (i.e. application software), you will want to use ASCII values instead of characters themselves in order to handle different character sets: for example to sort escort compare different characters.

Java program to print ASCII values from a to z

public class AsciiValues {

    public static void main(String[] args) {

        // Loop through characters 'a' to 'z'

        for (char ch = 'a'; ch <= 'z'; ch++) {

            // Print the character and its ASCII value

            System.out.println("Character: " + ch + ", ASCII Value: " + (int) ch);

        }

    }

}

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu