- Feb 16, 2003
- 26,108
- 5
- 81
I know this is in the wrong forum but it would help if I got a quick answer.
I'm writing a program asking for values, processing them, and then outputting a final result based upon all those. When the program asks for values (In the command prompt) and enters a value for each including 0, it works. But when the user just presses enter not including any value, it gives me this error:
I tried setting values for the variables the user gives values for before they are asked so they don't override the user's inputs, but that doesn't seem to help. Is there some code I can use which makes the program handle things not defined by the user as 0?
I'm writing a program asking for values, processing them, and then outputting a final result based upon all those. When the program asks for values (In the command prompt) and enters a value for each including 0, it works. But when the user just presses enter not including any value, it gives me this error:
Exception in thread "main" java.lang.NumberFormatException:
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:476)
at Change.main(Change.java:60)
Press any key to continue . . .
I tried setting values for the variables the user gives values for before they are asked so they don't override the user's inputs, but that doesn't seem to help. Is there some code I can use which makes the program handle things not defined by the user as 0?
