Java - Statement Print Square

Description

Print Square

Demo

public class Main {
  public static void main(String[] args) {

    int n = 15;/*from  ww  w  .ja  v  a 2s .c o  m*/
    String a = "*";
    String b = " ";

    for (int i = 0; i < n; i++) {
      System.out.print("*");

    }
    System.out.println();

    for (int i = 0; i < n - 2; i++) {
      System.out.print("*");
      for (int j = 0; j < n - 2; j++) {
        System.out.print(" ");
      }
      System.out.println("*");

    }

    for (int i = 0; i < n; i++) {
      System.out.print("*");

    }

  }

}

Related Example