Code compiling error

I was practising the prime numbers code simultaneously and for some reason that I can’t figure out my program wasn’t running and giving an error which said “n” command not found. The code is as follows could someone help correct it please.

import java.util.Scanner;

public class Prime
{
public static void main(String[] args)
{
Scanner scn = new Scanner(System.in);
int n = scn.newInt();

    int d = 2;
    boolean flag = true;

    while(d <= n-1)
    {
        if(n % d == 0)
        {
            flag = false;
        }
        d = d + 1;
    }
    if (flag == true)
    {
        System.out.println("Number is prime");
    }
    else
    {
        System.out.println("Not prime");
    }
}

}

@dhillonaditi53_b4c510c5fede596a When you have written int n = scn.newInt(); it should be int n = scn.nextInt() ;not int n = scn.newInt();
//Next not new

of course!!! Thank you so much

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.