Advertisement
dimipan80

Print the ASCII Table

Aug 3rd, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. /* Find online more information about ASCII (American Standard Code for Information Interchange)
  2.  * and write a program to prints the entire ASCII table of characters at the console (characters from 0 to 255).
  3.  * Note that some characters have a special purpose and will not be displayed as expected.
  4.  * You may skip them or display them differently. You may need to use for-loops (learn in Internet how). */
  5.  
  6. import java.util.Locale;
  7.  
  8. public class PrintTheASCII_Table {
  9.  
  10.     public static void main(String[] args) {
  11.         // TODO Auto-generated method stub
  12.         Locale.setDefault(Locale.ROOT);
  13.         for (int i = 0; i < 256; i++) {
  14.             if (i > 32 && i < 127 || i > 160) {
  15.                 System.out.printf("Character # %3d -> %s\n", i, (char) i);
  16.             } else {
  17.                 System.out.printf("Character # %3d -> Unprintable symbol or space !\n", i);
  18.             }
  19.  
  20.         }
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement