In this tutorial, we will write a program to print an inverted equilateral triangle in java. Before that, you may go through the following topic in java.
It is a Java Program to Print Reverse Pyramid Star Pattern or you can say upside-down equilateral triangle pattern in java.
The program takes the user input for the number of rows to be taken to print the reverse equilateral star pattern.
Example:
Input: number = 7
Output:
*************
***********
*********
*******
*****
***
*
Java program to print Inverted Equilateral Star Triangle
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int num, i, j, k;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the no. of rows: ");
num = sc.nextInt();
for (i = num; i > 0; i--)
{
for (j = 0; j < num - i; j++)
{
System.out.print(" ");
}
for (k = 0; k < i; k++)
{
System.out.print("*" + " ");
}
System.out.print("\n");
}
}
}
Output:

