Patterns
Java Program to Print Downward Triangle Star Pattern
A Java program to print a downward triangle star pattern.
Problem Description
Write a Java program to print a downward triangle star pattern.
Code
public class DownwardTrianglePattern {
public static void main(String[] args) {
int rows = 5;
for (int i = rows; i >= 1; --i) {
for (int j = 1; j <= i; ++j) {
System.out.print("* ");
}
System.out.println();
}
}
}Output
* * * * *
* * * *
* * *
* *
* Explanation
- Outer Loop: Starts from
rowsand decrements. - Inner Loop: Prints stars equal to the current row count.
