KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

A
AB
ABC
ABCD
ABCDE

Java

Java Nested for Loops

ICSE

21 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        
        for (char i = 'A'; i <= 'E'; i++) {
            for (char j = 'A'; j <= i; j++) {
                System.out.print(j);
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following pattern: A AB ABC ABCD ABCDE

Answered By

9 Likes