Java Program to Display Characters from A to Z using loop

In this program we will learn how to print English Alphabets in Upper case and Lower case using for loop.

Method 1: Display Uppercased A to Z using for loop

public class AtoZUpperCase{

    public static void main(String[] args) {

        char c;

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

Output

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Its as simple as that, not much of explanation, just a for loop which Starts with A and ends with Z while incrementing character.

Same thing we will do for lowercase alphabets also.

Method 2:  Display Lowercased a to z using for loop

public class AtoZLowercase{

    public static void main(String[] args) {

        char c;

        for(c = 'a'; c <= 'z'; ++c)
            System.out.print(c + " ");
    }
}

Output

a b c d e f g h i j k l m n o p q r s t u v w x y z

Leave a Reply