Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Write a C program to print all alphabets from a to z

Java program to display alphabets using loops

Posted on February 17, 2022February 23, 2022

Table of Contents

  • Java program to display alphabets using loops
    • Code to print all characters of alphabet
      • Code to print all characters of alphabet using for loop
      • Code to print all characters of alphabet using while loop
      • Code to print all characters of alphabet using do-while loop

Java program to display alphabets using loops

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

Code to print all characters of alphabet

Code to print all characters of alphabet using for loop

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

 

 

Code to print all characters of alphabet using while loop

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

 

Code to print all characters of alphabet using do-while loop

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

if statement in Java language

Nested if statements in Java language

Method in Java language

For loop in Java language

While loop in Java language

Do-while loop in Java language

Operator in Java language

Variable in Java language

Data type in Java language

class and main method in Java

 

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

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes