Table of Contents
In this article, we will discuss the concept of Java program to display all alphabets using loops
In this post, we are going to learn how to write a program to print all characters of English alphabet using for, while and do-while loop in Java language
In this code, we are going to learn how to print all characters of English alphabet using for loop in Java language
Program 1
public class Disp_Alphabet_LetAtoZ{ public static void main(String args[]){ char ch;// declare character variable System.out.print("Display Uppercase Alphabets \n"); for(ch='A'; ch<='Z'; ch++){ System.out.print(ch+" "); //display uppercase Alphabets with space using for loop } System.out.print("\n\nDisplay Lowercase Alphabets \n"); for(ch='a'; ch<='z'; ch++){ System.out.print(ch+" "); //display lowercase Alphabets with space using for loop } } }
When the above code is executed, it produces the following result
Display Uppercase Alphabets 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 Display Lowercase Alphabets 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
In this code, we are going to learn how to print all characters of English alphabet using while loop in Java language
Program 2
public class Disp_Alpha_LetAtoZ{ public static void main(String args[]){ char ch;// declare character variable System.out.print("Display Uppercase Alphabets \n"); ch='A'; while(ch<='Z'){ System.out.print(ch+" "); //display uppercase Alphabets with space using while loop ch++; } System.out.print("\n\nDisplay Lowercase Alphabets \n"); ch='a'; while(ch<='z'){ System.out.print(ch+" "); //display lowercase Alphabets with space using while loop ch++; } } }
When the above code is executed, it produces the following result
Display Uppercase Alphabets 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 Display Lowercase Alphabets 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
In this code, we are going to learn how to print all characters of English alphabet using do-while loop in Java language
Program 3
public class Disp_Alpha_LetterAtoZ{ public static void main(String args[]){ char ch;// declare character variable System.out.print("Display Uppercase Alphabets \n"); ch='A'; do{ System.out.print(ch+" "); //display uppercase Alphabets with space using o-while loop ch++; }while(ch<='Z'); System.out.print("\n\nDisplay Lowercase Alphabets \n"); ch='a'; do{ System.out.print(ch+" "); //display lowercase Alphabets with space using do-while loop ch++; }while(ch<='z'); } }
When the above code is executed, it produces the following result
Display Uppercase Alphabets 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 Display Lowercase Alphabets 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
Suggested post
Nested if statements in Java language
Do-while loop in Java language
Similar post
Java program to print all alphabets in given range
C program to print all alphabets in given range
C++ program to print all alphabets in given range
Java program to print all alphabets using loops
C program to print all alphabets using loops
C++ program to print all alphabets using loops
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.