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

63 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();
        }
    }
}

Variable Description Table

Program Explanation

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

22 Likes