Print a Hollow Rectangle Pattern by MistarAV

public class HollowRectanglePattern {
public static void main(String[] args) {
int rows = 5;
int columns = 10;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= columns; j++) {
if (i == 1 || i == rows || j == 1 || j
== columns) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}

 Output 

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

Comments

Popular posts from this blog

Google Apprenticeship 2023 scheme

Pattern in C Language By MistarAV