What id the error

import java.util.Scanner;

public class invertedHourGlass {

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

}

}

Hey @nikhilkapoor1999 I have made two changes to your code :
i) While loop condition has to be 2*n-1 not ‘n’
ii) here
if(row < nr/2+1)
{
nsp–;
nst+=2;
}
you have written row <= nr/2 + 1 but it should not contain equal to sign.

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.