when trying to provide an input to the code it generates error but if the inout is predefined code is working properly so, please help
The statement I am using for the input is
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
and the error generated is
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:7)