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

Add two numbers in Scala - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Goal Parser Interpretation LeetCode Solution - The Coding Shala

Maximum Population Year LeetCode Solution - The Coding Shala

Shell Script to find sum, product and average of given numbers - The Coding Shala