In this program, we are going to see how we can print alphabets in Java. The program is pretty simple and straight forward. Here ASCII value of the characters comes into the picture, we use the ASCII value of starting and end character to run the loop.
See also: Find ASCII value of a character
Logic
ASCII value of small letter “a” is 97 and for “z” it is 122, so we run the loop from 97 to 122 and then inside the loop we have to print the current character.
Program
# Printing a - z print("Alphabets from a - z are : ") # a = 97 and z = 122 for alpha in range(97, 123): print(chr(alpha), end=" ")
Output
Alphabets from a - z are:
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