In this tutorial, we will write a program to print the left triangle star pattern in java. Before that, you may go through the following topic in java.
Java Program to Print Left Triangle Star Pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import java.util.Scanner; public class Main { public static void main(String args[]) { int k = 5, num; int i, j; Scanner sc = new Scanner(System.in); System.out.print("Enter the number of rows: "); num = sc.nextInt(); for (i = 0; i < num; i++) { for (j = 2 *(num - i); j >= 0; j--) System.out.print(" "); for (j = 0; j <= i; j++) System.out.print("* "); System.out.println(); } } } |
Output: