Whats wrong here?

package Lecture1;

import java.util.Scanner;

public class Pattern21 {

public static void main(String[] args) {

Scanner scn = new Scanner(System.in) ;

	int n = scn.nextInt() ; 
	int nst=1;
	int nsp=2*n-3;
	
	//row
	int row=1;
	while (row<=n) {
		
		//star work
		for (int cst=1; cst <=nst; cst++) {
			System.out.print("*");
			
		}
		//space work
		for(int csp=1; csp <=nsp; csp++) {
			System.out.print("*");
			
		}
			//star work
			for (int cst=1; cst <=nst; cst++) {
				System.out.print("*");
				
			}
			
	
	//preparation
		System.out.println();
	nst=nst+1;
	nsp=nsp-2;
	row=row+1;

}
}

}

@kasturichakraborty36_24075fa79f00d4e8 Corrected Code : (Look in the comments for mistakes)


package Lecture1;
import java.util.Scanner;

public class Pattern21 {

public static void main(String[] args) {
Scanner scn = new Scanner(System.in) ;

	int n = scn.nextInt() ; 
	int nst=1;
    //Spaces should be 2*n-2 not 2*n-3
	int nsp=2*n-2;
	
	//row
	int row=1;
	while (row<=n) {
		
		//star work
		for (int cst=1; cst <=nst; cst++) {
			System.out.print("* ");
			
		}
		//space work
		for(int csp=1; csp <=nsp; csp++) {
            //you shoud have used spaces but mistakenly you used stars
			// System.out.print("*");
            System.out.print("  ");
			
		}
			//star work
			for (int cst=1; cst <=nst; cst++) {
				System.out.print("* ");
				
			}
			
	
	//preparation
		System.out.println();
	nst=nst+1;
	nsp=nsp-2;
	row=row+1;

}
}
} 

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.