Star Pattern 4 in Java

Table of Contents
class Pattern
  public static void main(String args[])
    for(int i = 1;i<= 5;i++)//This outer loop is for the rows
      for(int j =1;j<=i;j++)//This inner loop is for the columns


In this program, we will print the “*”, a number of times the current value of i.

Here, for the outer loop, I have taken the maximum value for i =5. Now, whenever the inner loop activates for a particular value of i, the value of “i” will become the ceiling value for j, thus it will print the “*” only till the current value of i.

Previous Star Pattern 3 in Java
Next Star Pattern 5 in Java

Leave a Reply