Java Program to Print Alphabets (A-Z and a-z) - The Coding Shala

Home >> Java Programs >> Print Alphabets

 In this post, we will learn how to display alphabets using the Java program.

Java Program to Print Alphabets

Write a Java program to print the alphabets (A-Z and a-z). We can use a for loop or while loop to print the alphabets.

Java Program: 

/**
 * https://www.thecodingshala.com/
 */

public class Main {

    public static void main(String[] args) {

        System.out.println("A-Z alphabets are: ");
        for(char ch = 'A'; ch <= 'Z'; ch++) {
            System.out.print(ch + " ");
        }

        System.out.println();
        System.out.println("a-z alphabets are: ");
        for(char ch = 'a'; ch <= 'z'; ch++) {
            System.out.print(ch + " ");
        }
    }
}

Output: 

A-Z alphabets 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 
a-z alphabets 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 


Other Posts You May Like
Please leave a comment below if you like this post or found some errors, it will help me to improve my content.

Comments

Popular Posts from this Blog

Time Complexity, Space Complexity, Asymptotic Notations - The Coding Shala

Java Method Overloading - The Coding Shala

Binary Number with Alternating Bits LeetCode Solution - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

Java Program to Find GCD or HCF of Two Numbers - The Coding Shala