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

Longest Substring Without Repeating Characters Java Program - The Coding Shala

Anti Diagonals - The Coding Shala

First Missing Positive Solution - The Coding Shala

Shell Script to Display the digits which are at odd positions in a given 5-digit number - The Coding Shala

Java Program to Reverse a String using Stack - The Coding Shala