Doubt in partice question of section 1 (pratice question 7)

does its have better code for this problem (section 1 pratice question 7) although my code is running but i think it is not much good code

package praticesec1;

import java.util.Scanner;

public class Pro7 {

public static void main(String[] args) {
	// TODO Auto-generated method stub

	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();
	for (int row = 1; row <= n; row++) {
		if (row == 1 || row == n) {
			for (int i = 1; i <= n; i++) {
				System.out.print("* ");
			}
		} else {

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

}

import java.util.Scanner;

public class Dobts {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int row = 1; row <= n; row++) {
if (row == 1 || row == n) {
for (int i = 1; i <= n; i++) {
System.out.print("* “);
}
} else {
System.out.print(”* “);
for (int j = 1; j <= n - 2; j++) {
System.out.print(” “);
}
System.out.print(”* ");
}
System.out.println();
}
}
}

System.out.print(” “); just one more space