Sir why I am getting correct output please tell sir

import java.util.Scanner;

public class Main{

public static void Main(String[] args){

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int nr = 2*n -1;

int nsp = n -1;

int nst = 1;

// row
int row = 1;
while(row <= nr){
  // work space 
	int csp = 1;
	while (csp <= nsp) {
		System.out.print(" ");
		csp++;
	}
		
		//work stars
		int cst = 1;
		while(cst <= nst) {
			System.out.print("*");
		
			cst++;
			
		}
			
		// prep
		System.out.println();
		if(row <= nr/2){
		  nst = nst +1;
		}
		else{
		  nst = nst - 1;
		}
		if(row <= nr/2){
		  nsp = nsp - 1;
		}
		else{
		  nsp = nsp + 1;
		}
		
    
}

}
}