Pattern -1

Home / Java Patterns / Pattern -1

Pattern -1


*****

*****

*****

*****


Solution:

  1. In this pattern, there are 4 rows and 5 columns
  2. It's a normal square pattern that prints * in the inner(column) loop


public class squarePattern {

  public static void main(String[] args) {


    // size of the square

    int size = 4;

    // outer loop

    for (int i = 0; i < size; i++) {

      // inner loop

      for (int j = 0; j < size; j++) {

        System.out.print("*");

      }

      System.out.println();

    }

  }

}