File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes My code isn't running on sites like codechef and oneide Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "My code isn Watch "My code isn New topic

My code isn't running on sites like codechef and oneide

Rahul Son

Joined: Sep 23, 2011
Posts: 1
My code is running correctly on my NetBeans6.5 IDE.But when I submitted it on CodeChef and OneIDE if gave runtime error
My Code is:

The error comes at the user input line for v.For BufferedReader its .........

Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(
at java.lang.Integer.parseInt(
at a.main(

And with using Scanner for user input.......

my code using Scanner as well...

the error msg is..........

Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(
at java.util.Scanner.nextInt(
at java.util.Scanner.nextInt(
at A01.main(

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.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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?
I agree. Here's the link:
subject: My code isn't running on sites like codechef and oneide
It's not a secret anymore!