Java Program to print Reverse hollow Pyramid with stars
Following java program is used to print reverse hollow Pyramid with '*' using for loop
import java.util.Scanner;
public class DownTrianglePattern {
public static void main(String[] args) {
int i, j, k, rows = 9;
for (i = rows; i >= 1; i--) {
for (j = i; j < rows; j++) {
System.out.print(" ");
}
for (k = 1; k <= (2 * i - 1); k++) {
if (k == 1 || i == rows || k == (2 * i - 1)) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
}
}
Output:
*****************
* *
* *
* *
* *
* *
* *
* *
*
Try it Online here: https://onecompiler.com/java/3x73966re