Latest :

Square Star Pattern Program In Java – Patterns

Java program to print square star pattern program. We have written the below print/draw square asterisk/star pattern program in four different ways with sample example and output, check it out. At the end of the program, we added compiler such that you can execute the below codes:

  • Print Square Star Pattern – Using For Loop
  • Print – Using While Loop
  • print – Using Do While Loop

Using Standard Java Program

Output:

Using For Loop

1) Read n value and store it into the variable n

2) The outer loop iterates n times with the structure for(i=0;i<n;i++).

3) The inner loop iterates n times with the structure for(j=0;j<n;j++).

4) The inner loop checks the condition j<n

5) Prints character for n rows and n columns.

Output:

Using While Loop

1) The outer while loop executes iterates until the condition i++<n is false.

2) The inner loop will display the character until the condition j++<n is false for every i value.

Output:

Using Do-While Loop

1) The outer do-while loop iterates until the condition ++i<n is false.

2) The inner loop prints the character until the condition ++j<n is false for each i value.

Output:

More Programs:

x

Check Also

Java Inverted Mirrored Right Triangle Star Pattern

Java program to print Inverted mirrored right triangle star pattern program. We have written below ...