How To Print The Alphabet in Java?

In Java, the primitive value of type char can be converted to the primitive int. An an integer within the range of a character can be converted to a char. For example, the ASCII character code for the character A is 65, for B is 66, etc. Because of a char value can be interchanged with the integer value that represents its character code I can create a loop that starts from the letter A and stops at the character Z and I increment one character at a time. Here is the code snippet to print each letter of the alphabet in a loop.

for(char c = 'A'; c <= 'Z'; c++) {
    System.out.print(c);
}

Related posts:

  1. Java String Conversion Puzzlers
  2. Print a PDF Document in Java
  3. Print HTML Using IE
  4. Can You Spot the Infinite Loop?
  5. Ruby Language Goodies For Java Developers
  6. Windows Print Screen Key


One Response to “How To Print The Alphabet in Java?”

Leave a Reply