Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:838)
Anyone please tell why is happening and how can I remove these errors which are not being shown on my IDE,infact both these codes are working well on my IDE but not on these sites compilers.Last night iI had to withdrew from an online competition because of this problem.
posted 4 years ago
For starters, never do this:
You simply MUST handle exceptions, especially I/O exceptions. At least print an error message someplace where you will see it.
It's hard to tell what the program will do without knowing the input you gave. I would guess that whatever string you ran through "parseInt" wasn't in fact an integer - it may have been empty or null.
In the future, please UseCodeTags. See how much easier to read the code is now?