Doubt in section 1 practice questions

not able to get desired output
program i wrote

package assignments;

import java.util.Scanner;

public class Question8 {

public static void main(String[] args) {
	Scanner scan =new Scanner(System.in);
	System.out.println("enter value of n");
	int n=scan.nextInt();
	int nst=1;
	int nsp=n-2;
	
	
	int row=1;
	while(row<=n)
	{
		if(row==1||row==n)
		{
			for(int cst=1;cst<=nst;cst++)
			{
				System.out.print("*");
			}
			for(int csp=1;csp<=nsp;csp++)
			{
				System.out.print(" ");
			}
			for(int cst=1;cst<=nst;cst++)
			{
				System.out.print("*");
			}
		
		}
		else if(n%2==0)
		{
			for(int i=1 ;i<n;)
			{
				System.out.print(" ");
				System.out.print("*");
				i=i+2;
			}
		}
		else
		{
			for(int i=1 ;i<=nsp;)	
			{
				if(i<nsp)
				{
				System.out.print(" ");
				}
				else
				{
					System.out.print("*");
				}
				i=i++;
			}
		}
		
		
		System.out.println();
		row++;
	
	
	
	
	}
}

}

I am not sure which pattern this code is for. Is it for the same pattern as that in the video you have shared or some other pattern from the practice questions? Please let me know so I can help you further

This question is regarding section 1 practice questions (question 8) able to get o/p with small modifications to the existing code but required code in short or less steps if possible

working code

package assignments;

import java.util.Scanner;

public class Question8 {

public static void main(String[] args) {
	Scanner scan =new Scanner(System.in);
	System.out.println("enter value of n");
	//n=5
	int n=scan.nextInt();
	int nst=1;
	int nsp=n-2;
	
	
	int row=1;
	while(row<=n)
	{
		if(row==1||row==n)
		{
			for(int cst=1;cst<=nst;cst++)
			{
				System.out.print("*");
			}
			for(int csp=1;csp<=nsp;csp++)
			{
				System.out.print(" ");
			}
			for(int cst=1;cst<=nst;cst++)
			{
				System.out.print("*");
			}
		
		}
		else if(row%2==0)
		{
			for(int i=1 ;i<n;)
			{
				System.out.print(" ");
				System.out.print("*");
				i=i+2;
			}
		}
		else
		{
			for(int i=1 ;i<=nsp;i++)	
			{
				if(i<nsp)
				{
				System.out.print(" ");
				}
				else
				{
					System.out.print("*");
				}
				
			}
		}
		
		
		System.out.println();
		row++;
	
	
	
	
	}
}

}