Java Code To Check Print Square Pattern Program

March 23, 2023

Program:

public class squarePattern 
{
       public static void main(String[] args) 
       {
             int size=9;
             for(int i=0;i<size;i=i+2) 
	     {
                      for(int j=0;j<size;j++) 
	              {
			  System.out.print("*");
	              }
		          System.out.println();
             }
       }
}

Compile:

javac squarePattern.java
 java squarePattern

Output:

*********
*********
*********
*********
*********

You Might Also Like