Exception in taking input

–>
Scanner in=new Scanner(System.in);
int n,i=0;
n=in.nextInt();
String arr[]=new String[n];
–>
These are my coding lines and the exception given are as follow–

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)

@preet25.pc,
Can you share your complete code?

Hi,
This problem comes when you don’t provide enough number of inputs to stdin.
Some ide needs input values in advance,
Just provide your input array in advance before execution.

Thanks

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.