Why do I keep getting the same runtime error for all my codes? Can somebody help? For eg. I am getting the error:
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 Life.main(Main.java:13)
for the problem CHFAR. The link to my solution is https://www.codechef.com/viewsolution/23614063. I get the runtime error whenever I take input. Like in line 13 ‘int n= reader.nextInt();’.
try{
//Your code
}
catch(Exception ex)
{
return;
}
Main.java:42: error: class, interface, or enum expected
catch(Exception ex)
^
Main.java:45: error: class, interface, or enum expected
}
^
2 errors
Got this compilation error. https://www.codechef.com/viewsolution/23615496
Check your code link. You are sharing code of some HTML code submitted in Java.
Saw you got AC. Have you figured out the issue or you still need help?
I have figured out the issue. Thanks though. I might need help in the future.