+ 1
Help me solve the code guys...never dealt with an exception before...
4 Antworten
+ 1
I got a NumberFormatException which means the program tried to turn something into a number that couldn't be done e.g. trying to convert "Bob" into a number
+ 1
The second call to readLine() on the BufferedReader returned null, because you've already taken the first number (this is assuming you input one number) so parseInt will fail to work and throw the exception. You could verify that you have enough inputs before making the call or use a try-catch block to handle the exception. You should really verify the inputs first, and not use a catch to control the flow of the program
0
so how do I solve it?
0
shall I create a subclass so that the second call to readLine() does not return null and fail?
I don't know any other exception other than catch which can control the flow of the program..
how to verify inputs?