Skip to main content

Java program to print alphabets

Java program to print alphabets

Java program to print alphabets on screen, i.e., a, b, c, ..., z; in lower case.

Java source code

  1. class Alphabets
  2. {
  3.    public static void main(String args[])
  4.    {
  5.       char ch;
  6.  
  7.       for (ch = 'a'; ch <= 'z'; ch++)
  8.          System.out.println(ch);
  9.    }
  10. }
You can easily modify the above java program to print alphabets in upper case.
Download Alphabets program class file.
Output of program:

Printing alphabets using a while loop (Only the body of the main method is shown):
  1. char c = 'a';
  2.  
  3. while (<= 'z') {
  4.   System.out.println(c);
  5.   c++;
  6. }
Using a do while loop:
  1. char c = 'A';
  2.  
  3. do {
  4.   System.out.println(c);
  5.   c++;
  6. } while (<= 'Z');

Comments

Popular posts from this blog

Java program to print multiplication table

Java program to print multiplication table of a number entered by a user using a  for  loop. You can modify it for  while  or  do while  loop for practice. Using nested loops (a loop inside another loop), we can print tables of numbers between a given range say a to b, for example, if the input numbers are '3' and '6' then tables of '3', '4', '5' and '6' will be printed. Java programming source code import   java.util.Scanner ;   class   MultiplicationTable {     public   static   void   main ( String   args [ ] )     {       int   n, c ;       System . out . println ( "Enter an integer to print it's multiplication table" ) ;     Scanner in   =   new   Scanner ( System . in ) ;     n   =   in. nextInt ( ) ;       System . out . println ( "Multiplication table of "   + ...

Use phone camera as a webcam without root in Hindi/urdu.