Scanner error

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(
at java.util.Scanner.nextInt(
at java.util.Scanner.nextInt(
at Codechef.main(

Giving run time error : NZEC
I am getting error while taking input with scanner .
If I run same code in eclipse I am not getting any error.

Code snippet:

import java.util.;
import java.lang.

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
public static void main (String[] args) throws java.lang.Exception
// your code goes here
Scanner inp=new Scanner(;
int t=inp.nextInt();

The error you are facing can be resolved by ticking on Custom Input and give the input you want.In java, if you use Scanner then you have to tick custom input, I do not know why in online IDE it is compulsory but you have no choice if you are using Scanner.

Hope this will help you!!! @srikar_ganta

Which problem are you talking about? Also, could you give us the submission link?

1 Like