Pattern 7

i want to make my code better

question *****
* *
* *
* *
*****

Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

//code for *****
int row = 1;
int star=1;
while (star<=n) {
System.out.print("");
star++;
}
System.out.println();
row++;
//code for * *
while (row<=n-1) {
int nst = 1;
while (nst<=n) {
if (nst == 1) {
System.out.print("
");
}

else if (nst>1 && nst<n) {
	System.out.print(" ");

}
	else if (nst==n) {
	System.out.print("*");

}


nst++;

}
  System.out.println();
	row++;
	//code for *****
	while (row==n) {
		int mass=1;
		while (mass<=n) {
			System.out.print("*");
			mass++;
		
	}
		row++;
	}
	
	}
}

}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.