KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

15 14 13 12 11
10 9 8 7
6 5 4
3 2
1

Java

Java Nested for Loops

ICSE

51 Likes

Answer

public class KboatPattern
{
    public void displayPattern() {
        int a = 15;
        for (int i = 5; i > 0; i--) {
            for (int j = 1; j <= i; j++) {
                System.out.print(a-- + "\t");
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following pattern: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Answered By

20 Likes