Pattern not appearing

the second group pf stars is not appearing even though i have written the same code. it is as copied below:

package practicequestions;

import java.util.Scanner;

public class pq17 {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	
	int row=1;
	int nst=n/2;
	int nsp=1;
	
	while(row<=n) {
		int cst=1;
		int csp=1;
		while(cst<=nst) {
			System.out.print("*");
			cst++;
		}
		
		while(csp<nsp) {
			System.out.print(" ");
			csp++;
		}
		
		while(cst<=nst) {
			System.out.print("*");
			cst++;
		}
		
		System.out.println();
		if(row<=n/2) {
			nst=nst-1;;
			nsp=nsp+2;
			
		}
		else {
			nst=nst+1;
			nsp=nsp-2;
		}
		row++;
	}

}

}

Hi Amandeep,
Before printing the second grp stars you have to reinitialize cst to 1 as after printing stars of 1st grp cst will be greater than nst and that’s why your code is not printing the stars for second grp

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.