Java Program to Print ASCII Value of All Alphabets

  • Write a Java program to print ASCII Value of all characters.
  • Java program to print ascii value of all uppercase alphabets.

ASCII value is the integer value corresponding to an alphabet. Every alphabet in java programming language is stored as it's ASCII value in memory location. When we store a character in a variable of data type char, the ASCII value of character is stored instead of that character itself.

For Example,
ASCII value of 'A' is 65
ASCII value of 'S' is 83

A character and it's ASCII value can be used interchangeably. The ASCII value of alphabets are consecutive natural numbers. We can perform all arithmetic operations on characters line 'B' + 3, 'B'/4 etc. If any expression contains a character then it's corresponding ASCII value is used in expression.

Java program to print ASCII value of all characters

package com.tcc.java.programs;

public class AsciiValue {
    public static void main(String args[]) {
        int i;
        for(i = 0; i < 26; i++){
            System.out.println((char)('A'+i) + " --> " + ('A'+i));
            
         }
    }
}
Output
A --> 65
B --> 66
C --> 67
D --> 68
E --> 69
F --> 70
G --> 71
H --> 72
I --> 73
J --> 74
K --> 75
L --> 76
M --> 77
N --> 78
O --> 79
P --> 80
Q --> 81
R --> 82
S --> 83
T --> 84
U --> 85
V --> 86
W --> 87
X --> 88
Y --> 89
Z --> 90