display alphabets using loops
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
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.