pattern_4.java
1 /* 2 * Write code to print the following pattern 3 * 4 * * * * * * * * * * 5 * * * * * * * * 6 * * * * * * 7 * * * * 8 * * 9 */ 10 11 public class pattern_4 { 12 public static void main(String[] args) { 13 int n = 5; 14 15 for (int i = n; i >= 1; i--) { 16 for(int j = 1; j <= (n - i); j++) { 17 System.out.print(" "); 18 } 19 20 for(int j = 1; j <= (2 * i - 1); j++) { 21 System.out.print("* "); 22 } 23 24 System.out.println(); 25 } 26 } 27 }