Star Pattern 2 in Java

Table of Contents

Star Pattern 2 in Java

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<=5;j++)//This inner loop is for the columns
      {
        System.out.print("i");//This will print the current value of i
      }
     System.out.println();
     }
  }
}

Discussion

The logic behind this program is similar to the previous one, just instead of printing the “*”, each time we have to print the current value of i.

11111
22222
33333
44444
55555
Previous Star Pattern 1 in Java
Next Star Pattern 3 in Java

Leave a Reply