Program which print 11X11 (11 rows by 11 columns) star rectangle and also one star in the center
public class MainJavaStarsRectangle {
public static void main(String[] args) {
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
if (i == 0 || i == 10) {
System.out.print("*");
} else if (j == 0 || j == 10) {
System.out.print("*");
} else if (i == 5 && j == 5) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
Output:
***********
* *
* *
* *
* *
* * *
* *
* *
* *
* *
***********