Skip to content

Commit

Permalink
Square Pattern in Java
Browse files Browse the repository at this point in the history
Created an Square pattern in Java
  • Loading branch information
Shakeelkhuhro authored Oct 3, 2022
1 parent 41bfff4 commit 6d79eaf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Java/SqurePattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Java Program to Print Square Pattern

import java.io.*;

class GFG {

static void print_rectangle(int k, int l)
{
int a;
int b;

// Outer loop for rows
for (a = 1; a <= k; a++) {
// Inner loop for columns
for (b = 1; b <= l; b++) {
if (a == 1 || a == k || b == 1 || b == l)

System.out.print("*");
else

System.out.print(" ");
}
System.out.println();
}
}

public static void main(String args[])
{
int rows = 8;
int columns = 22;

// Calling the method
print_rectangle(rows, columns);
}
}

0 comments on commit 6d79eaf

Please sign in to comment.