NoSuchElementException

I am getting this exception on Scanner while running my code.
On my IDE its working fine
Can someone help?

1 Like

While taking inputs Don’t directly use scanner.nextInt() first check if(scanner.hasNext()) and then get the input.

1 Like

Give sample input otherwise it will keep showing that error.

Otherwise what to do? @vicky281999

So i wont be able to submit? @l_returns

you can submit. It should work fine after you submit. If it doesn’t check if your code matches with given input format.
For running it on codechef ide : you will have to provide input ( in custom input section) whenever you scan something. if it doesn’t find the input then it will give runtime error.
Write input according to format (in custom input) before clicking on run.

Same question asked many times from each newcomers on codechef. You can find the reason for this error with explanation. Visit this.

2 Likes

Okay thanks @l_returns

1 Like

Okay ill check @gjaiswal108