Snippet : Get ASCII Value For Every Characters

This snippet helps you to get the ASCII value for every characters.
public class ascii
{
    public static void main(String [] args)
    {
        String alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
        for (int i=0; i<alph.length();i++)
        System.out.println(alph.charAt(i) + " - ASCII : " + (int)alph.charAt(i) );
    }
}
You can add as much as characters you want, just add them to String alph. Here's the result I got :
A - ASCII : 65
B - ASCII : 66
C - ASCII : 67
D - ASCII : 68
E - ASCII : 69
F - ASCII : 70
G - ASCII : 71
H - ASCII : 72
I - ASCII : 73
J - ASCII : 74
K - ASCII : 75
L - ASCII : 76
M - ASCII : 77
N - ASCII : 78
O - ASCII : 79
P - ASCII : 80
Q - ASCII : 81
R - ASCII : 82
S - ASCII : 83
T - ASCII : 84
U - ASCII : 85
V - ASCII : 86
W - ASCII : 87
X - ASCII : 88
Y - ASCII : 89
Z - ASCII : 90
0 - ASCII : 48
1 - ASCII : 49
2 - ASCII : 50
3 - ASCII : 51
4 - ASCII : 52
5 - ASCII : 53
6 - ASCII : 54
7 - ASCII : 55
8 - ASCII : 56
9 - ASCII : 57
As you can see I have added A-Z & 0-9.

Post a Comment

Note: Only a member of this blog may post a comment.