Java Program to Display Alphabets from a to z

Write a Java Program to display Alphabets from a to z using for loop, while loop, and do while loop. In this Java example, all the loops iterate from alphabets a to z and display them as an output.

public class Alphabetsatoz1 {
	public static void main(String[] args) {	
		char lwch;
		
		for(lwch = 'a'; lwch <= 'z'; lwch++) 
		{
			System.out.print(lwch + " ");
		}
		System.out.println();
		
		
		char lwch1 = 'a';
		while (lwch1 <= 'z') 
		{
			System.out.print(lwch1 + " ");
			lwch1++;
		}
		System.out.println();
		
		
		char lwch2 = 'a';
		do 
		{
			System.out.print(lwch2 + " ");
		} while (++lwch2 <= 'z');
	}
}
Java Program to Display Alphabets from a to z 1

This Java program to display a to z iterates the ASCII codes from 97 to 122, representing the alphabets a to z and prints them.

public class Alphabetatoz2 {

	public static void main(String[] args) {
			
		for(int i = 97; i <= 122; i++) 
		{
			System.out.printf("%c ", i);
		}
	}
}
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 

This Java display Alphabets from a to z program allows users to enter the starting lowercase alphabet and prints the remaining lowercase alphabets up to z.

import java.util.Scanner;

public class Alphabetatoz3 {
	
	private static Scanner sc;

	public static void main(String[] args) {
			
		char ch, strlwChar;
		sc= new Scanner(System.in);

		System.out.print("Please Enter any Character =  ");
		strlwChar = sc.next().charAt(0);
		
		for(ch = strlwChar; ch <= 'z'; ch++) {
			System.out.print(ch + " ");
		}
	}
}
Please Enter any Character =  h
h i j k l m n o p q r s t u v w x y z