ASCII in Java


Computer manufacturers agreed to use one code called the ASCII (American Standard Code for Information Interchange).There are 128 standard ASCII characters, numbered from 0 to 127. Extended ASCII adds another 128 values and goes to 255. The ASCII values to print using to the for loop. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The three components of the for loop (separated by ;) are variable declaration/initialization , the condition , and the increment statement.

Source Code

public class ascii {
    public static void main(String args[])
    {
        /*
            ASCII  -  American Standard Code For Information Interchange
 
            Computers can only understand numbers,
            so an ASCII code is the numerical representation of a character such as 'a' or '@' etc.
 
            The first 32 characters in the ASCII-table
            are unprintable control codes and are used to control peripherals such as printers.
 
            Codes 32-127 are common for all the different variations of the ASCII table, they are
            called printable characters, represent letters, digits, punctuation marks,
            and a few miscellaneous symbols.
 
            65-90  A-Z
            97-122 a-z
            48-57  0-9
            Space  32
        */
        for(int i=65;i<=90;i++)
        {
            System.out.println(i+" "+(char)i);
        }
 
    }
}
 

Output

65 A
66 B
67 C
68 D
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
To download raw file Click Here

Basic Programs