public class ASCII
{
public static void main(String[] args)
{
int i;
for (i = 0; i <= 127; i++)
{
System.out.println(" The ASCII value of " + (char) i + "=" + i);
}
}
}
Compile:
javac ASCII.java
java ASCII
Output:
The ASCII value of =0
The ASCII value of =1
The ASCII value of =2
The ASCII value of =3
The ASCII value of =4
The ASCII value of =5
The ASCII value of =6
The ASCII value of =7
The ASCII value of =8
The ASCII value of =9
The ASCII value of =10
The ASCII value of =11
The ASCII value of =12
The ASCII value of =13
The ASCII value of =14
The ASCII value of =15
The ASCII value of =16
The ASCII value of =17
The ASCII value of =18
The ASCII value of =19
The ASCII value of .=20
The ASCII value of =21
The ASCII value of =22
The ASCII value of =23
The ASCII value of =24
The ASCII value of =25
The ASCII value of =26
The ASCII value of =27
The ASCII value of =28
The ASCII value of =29
The ASCII value of =30
The ASCII value of =31
The ASCII value of =32
The ASCII value of !=33
The ASCII value of "=34
The ASCII value of #=35
The ASCII value of $=36
The ASCII value of %=37
The ASCII value of &=38
The ASCII value of '=39
The ASCII value of (=40
The ASCII value of )=41
The ASCII value of *=42
The ASCII value of +=43
The ASCII value of ,=44
The ASCII value of -=45
The ASCII value of .=46
The ASCII value of /=47
The ASCII value of 0=48
The ASCII value of 1=49
The ASCII value of 2=50
The ASCII value of 3=51
The ASCII value of 4=52
The ASCII value of 5=53
The ASCII value of 6=54
The ASCII value of 7=55
The ASCII value of 8=56
The ASCII value of 9=57
The ASCII value of :=58
The ASCII value of ;=59
The ASCII value of <=60
The ASCII value of ==61
The ASCII value of >=62
The ASCII value of ?=63
The ASCII value of @=64
The ASCII value of A=65
The ASCII value of B=66
The ASCII value of C=67
The ASCII value of D=68
The ASCII value of E=69
The ASCII value of F=70
The ASCII value of G=71
The ASCII value of H=72
The ASCII value of I=73
The ASCII value of J=74
The ASCII value of K=75
The ASCII value of L=76
The ASCII value of M=77
The ASCII value of N=78
The ASCII value of O=79
The ASCII value of P=80
The ASCII value of Q=81
The ASCII value of R=82
The ASCII value of S=83
The ASCII value of T=84
The ASCII value of U=85
The ASCII value of V=86
The ASCII value of W=87
The ASCII value of X=88
The ASCII value of Y=89
The ASCII value of Z=90
The ASCII value of [=91
The ASCII value of \=92
The ASCII value of ]=93
The ASCII value of ^=94
The ASCII value of _=95
The ASCII value of `=96
The ASCII value of a=97
The ASCII value of b=98
The ASCII value of c=99
The ASCII value of d=100
The ASCII value of e=101
The ASCII value of f=102
The ASCII value of g=103
The ASCII value of h=104
The ASCII value of i=105
The ASCII value of j=106
The ASCII value of k=107
The ASCII value of l=108
The ASCII value of m=109
The ASCII value of n=110
The ASCII value of o=111
The ASCII value of p=112
The ASCII value of q=113
The ASCII value of r=114
The ASCII value of s=115
The ASCII value of t=116
The ASCII value of u=117
The ASCII value of v=118
The ASCII value of w=119
The ASCII value of x=120
The ASCII value of y=121
The ASCII value of z=122
The ASCII value of {=123
The ASCII value of |=124
The ASCII value of }=125
The ASCII value of ~=126
The ASCII value of =127