Java program to print alphabets code example

Example 1: Java program to print alphabets

public class PrintAlphabetUsingForLoop
{
   public static void main(String[] args)
   {
      System.out.println("Printing alphabets from a to z : ");
      char alphabet;
      for(alphabet = 'a'; alphabet <= 'z'; alphabet++)
      {
         System.out.println(alphabet);
      }
   }
}

Example 2: java program to display characters from a to z using loop

public class Characters {

    public static void main(String[] args) {

        char c;

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

Tags:

Java Example