Write a Java Program which will Print Square Pattern. |EasyCoding45

Write a Java Program that will Print Square Pattern.

Printing patterns in Java is a common exercise for beginners to practice programming logic. You can use nested loops to control the structure of the pattern.

Program : (Write a Java Program that will Print a Square Pattern.)


public class SquarePattern {
    public static void main(String[] args) {
        int rows = 5;

        for (int i = 1; i <= rows; i++) {
            for (int j = 1; j <= rows; j++) {
                System.out.print("* ");
            }
            System.out.println();
        }
    }
}

Output :

https://easycoding45.blogspot.com/2023/11/write-java-program-which-will-print_01177418302.html



Comments