Java Program to print ASCII Value of all Characters

Write a Java Program to print ASCII Value of all Characters with example. In Java programming, each character has its unique ASCII value.

Java Program to print ASCII Value of all Characters using For Loop

This program prints ASCII values of all the characters currently present. As you know, the ASCII values of all the characters in Java are between 0 and 255. That’s why we used for loop to start at 0 and ends at 255.

TIP: Please refer ASCII Table article in Java to understand the list of ASCII Characters and their decimal, Hexadecimal, and Octal numbers.

// Java Program to print ASCII Value of all Characters using For Loop
public class ASCIIofAllCharacters {
	public static void main(String[] args) 
	{
		int i;
		
		for(i = 0; i <= 255; i++)
		{
			System.out.println(" The ASCII value of " + (char)i + "  =  " + i);
		}
	}
}
Java Program to print ASCII Value of all Characters 1

Java Program for ASCII Value of all Characters using While Loop

This Java program displays the ASCII values of all the existing characters using While Loop.

// Java Program to print ASCII Value of all Characters using While Loop
public class ASCIIofAllCharacters1 {
	public static void main(String[] args) 
	{
		int i = 0;
		
		while(i <= 255)
		{
			System.out.println(" The ASCII value of " + (char)i + "  =  " + i);
			i++;
		}
	}
}

We just replaced the For loop in the above Java example with the While loop. So, please refer While Loop article here: WHILE LOOP.

 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 ¡  =  161
 The ASCII value of ¢  =  162
 The ASCII value of £  =  163
 The ASCII value of ¤  =  164
 The ASCII value of ¥  =  165
 The ASCII value of ¦  =  166
 The ASCII value of §  =  167
 The ASCII value of ¨  =  168
 The ASCII value of ©  =  169
 The ASCII value of ª  =  170
 The ASCII value of «  =  171
 The ASCII value of ¬  =  172
 The ASCII value of ­  =  173
 The ASCII value of ®  =  174
 The ASCII value of ¯  =  175
 The ASCII value of °  =  176
 The ASCII value of ±  =  177
 The ASCII value of ²  =  178
 The ASCII value of ³  =  179
 The ASCII value of ´  =  180
 The ASCII value of µ  =  181
 The ASCII value of ¶  =  182
 The ASCII value of ·  =  183
 The ASCII value of ¸  =  184
 The ASCII value of ¹  =  185
 The ASCII value of º  =  186
 The ASCII value of »  =  187
 The ASCII value of ¼  =  188
 The ASCII value of ½  =  189
 The ASCII value of ¾  =  190
 The ASCII value of ¿  =  191
 The ASCII value of À  =  192
 The ASCII value of Á  =  193
 The ASCII value of   =  194
 The ASCII value of à =  195
 The ASCII value of Ä  =  196
 The ASCII value of Å  =  197
 The ASCII value of Æ  =  198
 The ASCII value of Ç  =  199
 The ASCII value of È  =  200
 The ASCII value of É  =  201
 The ASCII value of Ê  =  202
 The ASCII value of Ë  =  203
 The ASCII value of Ì  =  204
 The ASCII value of Í  =  205
 The ASCII value of Î  =  206
 The ASCII value of Ï  =  207
 The ASCII value of Ð  =  208
 The ASCII value of Ñ  =  209
 The ASCII value of Ò  =  210
 The ASCII value of Ó  =  211
 The ASCII value of Ô  =  212
 The ASCII value of Õ  =  213
 The ASCII value of Ö  =  214
 The ASCII value of ×  =  215
 The ASCII value of Ø  =  216
 The ASCII value of Ù  =  217
 The ASCII value of Ú  =  218
 The ASCII value of Û  =  219
 The ASCII value of Ü  =  220
 The ASCII value of Ý  =  221
 The ASCII value of Þ  =  222
 The ASCII value of ß  =  223
 The ASCII value of à  =  224
 The ASCII value of á  =  225
 The ASCII value of â  =  226
 The ASCII value of ã  =  227
 The ASCII value of ä  =  228
 The ASCII value of å  =  229
 The ASCII value of æ  =  230
 The ASCII value of ç  =  231
 The ASCII value of è  =  232
 The ASCII value of é  =  233
 The ASCII value of ê  =  234
 The ASCII value of ë  =  235
 The ASCII value of ì  =  236
 The ASCII value of í  =  237
 The ASCII value of î  =  238
 The ASCII value of ï  =  239
 The ASCII value of ð  =  240
 The ASCII value of ñ  =  241
 The ASCII value of ò  =  242
 The ASCII value of ó  =  243
 The ASCII value of ô  =  244
 The ASCII value of õ  =  245
 The ASCII value of ö  =  246
 The ASCII value of ÷  =  247
 The ASCII value of ø  =  248
 The ASCII value of ù  =  249
 The ASCII value of ú  =  250
 The ASCII value of û  =  251
 The ASCII value of ü  =  252
 The ASCII value of ý  =  253
 The ASCII value of þ  =  254
 The ASCII value of ÿ  =  255