KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

AAAAA
BBBB
CCC
DD
E

Java

Java Nested for Loops

ICSE

9 Likes

Answer

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

Output

BlueJ output of Write a program in Java to display the following pattern: AAAAA BBBB CCC DD E

Answered By

6 Likes