Java Program to Print Downward Triangle Star Pattern

Write a Java program to print the downward triangle star pattern using for loop.

package ShapePrograms2;

import java.util.Scanner;

public class DownwardTriangle1 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Triangle Star Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Downward Triangle Star Pattern");
		
		for (int i = rows -1 ; i >= 0; i-- ) 
		{
			for (int j = 0 ; j <= i; j++ ) 
			{
				System.out.print("* ");
			}
			System.out.println();
		}
	}
}
Java Program to Print Downward Triangle Star Pattern

This Java example displays the downward triangle pattern of stars using a while loop.

package ShapePrograms2;

import java.util.Scanner;

public class DownwardTriangle2 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Triangle Star Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Downward Triangle Star Pattern");
		
		int j, i = rows - 1 ;
		
		while ( i >= 0) 
		{
			j = 0 ;
			
			while ( j <= i ) 
			{
				System.out.print("* ");
				 j++;
			}
			System.out.println();
			i--;
		}
	}
}
Enter Downward Triangle Star Pattern Rows = 8
Printing Downward Triangle Star Pattern
* * * * * * * * 
* * * * * * * 
* * * * * * 
* * * * * 
* * * * 
* * * 
* * 
* 

Java program to print downward triangle star pattern using do while loop.

package ShapePrograms2;

import java.util.Scanner;

public class DownwardTriangle3 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Triangle Star Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Downward Triangle Star Pattern");
		
		int j, i = rows - 1 ;
		
		do
		{
			j = 0 ;
			
			do
			{
				System.out.print("* ");

			} while ( ++j <= i );
			
			System.out.println();
			
		} while ( --i >= 0);
	}
}
Enter Downward Triangle Star Pattern Rows = 14
Printing Downward Triangle Star Pattern
* * * * * * * * * * * * * * 
* * * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * 
* * * * * * * * 
* * * * * * * 
* * * * * * 
* * * * * 
* * * * 
* * * 
* * 
*

In this Java example, the DownwardTrianglePattern function prints the downward triangle pattern of a given symbol.

package ShapePrograms2;

import java.util.Scanner;

public class DownwardTriangle4 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Triangle Star Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.print("Enter Character for Downward Triangle Pattern = ");
		char ch = sc.next().charAt(0);
		
		System.out.println("Printing Downward Triangle Pattern");
		DownwardTrianglePattern(rows, ch);
	}
	
	public static void DownwardTrianglePattern(int rows, char ch) {
		for (int i = rows -1 ; i >= 0; i-- ) 
		{
			for (int j = 0 ; j <= i; j++ ) 
			{
				System.out.print(ch + " ");
			}
			System.out.println();
		}
	}
}
Enter Downward Triangle Star Pattern Rows = 14
Enter Character for Downward Triangle Pattern = #
Printing Downward Triangle Pattern
# # # # # # # # # # # # # # 
# # # # # # # # # # # # # 
# # # # # # # # # # # # 
# # # # # # # # # # # 
# # # # # # # # # # 
# # # # # # # # # 
# # # # # # # # 
# # # # # # # 
# # # # # # 
# # # # # 
# # # # 
# # # 
# # 
#