Java program to display alphabets (a to z) using loop

h‮‬ttps://www.theitroad.com

Here's a Java program to display the alphabets (a to z) using a loop:

public class Main {
    public static void main(String[] args) {
        char ch;

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

In this program, we initialize a char variable ch with the value 'a'.

We then use a for loop to print all the alphabets from a to z. In each iteration of the loop, we print the current value of ch and then increment it using the ++ operator.

The loop continues until ch becomes greater than 'z'.

The output of this program will be:

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

Note that we use the print method to print each alphabet on the same line, separated by a space. If you want to print each alphabet on a separate line, you can use the println method instead.