Write a program to print all alphabets from a to z


This Java program is used to print all the lowercase alphabets in the English language. Here's a step-by-step breakdown of how the program works:

  • The Alphabet class is defined and the main method is declared.
  • Inside the main method, a character variable s is declared but not initialized.
  • The program enters a for loop that will execute as long as the value of s is less than or equal to the character 'z'.
  • Inside the for loop, the program prints the current value of s to the console using the println() method of the System.out object.
  • The value of s is then incremented by one using the ++ operator.
  • The program returns to the beginning of the for loop and checks the condition again. If the value of s is still less than or equal to the character 'z', the loop will continue to execute. If not, the loop will terminate and the program will exit.

Source Code

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

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

Example Programs