Problem in pattern17

package patterns;

import java.util.Scanner;

public class pattern7 {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int nst = 1;
	int nsp = n / 2;

	int row = 1;
	while (row <= n) {
		// star work
		int i = 1;
		while (i <= nst) {
			System.out.print("*");
			i++;
		} // space work
		int j = 1;
		while (j <= nsp) {
			System.out.print(" ");
			j++;
		}
		int k = 1;
		while (k <= nst) {
			System.out.print("*");
			k++;
		}
		System.out.println();
		if (row <= n / 2) {
			nst = nst - 1;
			nsp = nsp + 2;
		} else {
			nst = nst + 1;
			nsp = nsp - 2;
		}
		row++;

	}

}

}

Hey @mishikasrvastava
Set
int nsp = 1;
int nst = n / 2;
correct code :
import java.util.Scanner;

public class pattern7 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int nsp = 1;
int nst = n / 2;

int row = 1;
while (row <= n) {
	// star work
	int i = 1;
	while (i <= nst) {
		System.out.print("*");
		i++;
	} // space work
	int j = 1;
	while (j <= nsp) {
		System.out.print(" ");
		j++;
	}
	int k = 1;
	while (k <= nst) {
		System.out.print("*");
		k++;
	}
	System.out.println();
	if (row <= n / 2) {
		nst = nst - 1;
		nsp = nsp + 2;
	} else {
		nst = nst + 1;
		nsp = nsp - 2;
	}
	row++;

}

}
}