Java program to Print Square Pattern of Star Character

Here is a Java program to print square pattern of '*' character.


Java program to print square pattern of star character

package com.tcc.java.programs;

import java.util.*;

public class SquarePattern {
    public static void main(String args[]) {
        int rows, i, j;

        Scanner in = new Scanner(System.in);
        System.out.println("Enter number 
            of rows in square pattern");
        rows = in.nextInt();

        /* Row iterator for loop */
        for(i = 0; i < rows; i++){
            /* Column iterator for loop */
            for(j = 0; j < rows; j++){
                System.out.print("*");
            }
            System.out.print("\n");
        }
    }
}
Output
Enter number of rows in square pattern
6
******
******
******
******
******
******

Recommended Posts
Java Program to Print Diamond Pattern of Star Character
Java Program to Print Pyramid Pattern of Stars
Java Program to Print Multiplication Table Triangle Pattern
Java Program to Print Right Triangle Star Pattern
Java Program to Print Pascal Triangle
Java Program to Print Inverted Pyramid Pattern of Stars
Java Program to Print Right Triangle Pattern of Natural Numbers
Java Program to Check Whether two Strings are Equal or Not
Java Program to Print Inverted Right Triangle Star Pattern
Java Program to Delete a Word from Sentence
Java Program to Concatenate Two Strings
All Java Programs