10/17/2017
Java program to print alphabets
admin admin

Java program to print alphabets

This program print alphabets on screen i.e a, b, c, ..., z. Here we print alphabets in lower case.

Java source code

class Alphabets
{
   public static void main(String args[])
   {
      char ch;
 
      for( ch = 'a' ; ch <= 'z' ; ch++ )
         System.out.println(ch);
   }
}

You can easily modify the above java program to print alphabets in upper case.

Download Alphabets program class file.

Output of program:
alphabets

Printing alphabets using while loop (only body of main method is shown):

char c = 'a';
 
while (c <= 'z') {
  System.out.println(c);
  c++;
}

Using do while loop:

char c = 'A';
 
do {
  System.out.println(c);
  c++;
} while (c <= 'Z');

  • VIA
  • admin
  • TAGS



LEAVE A COMMENT

Facebook Conversations

FOLLOW US