← Back to Exceptions
Question 768
Recover With a Default Value
Recover With a Default Value
Try to parse the input into a variable namedvalue. If parsing throws aFormatException, recover by settingvalueto-1inside the catch. After thetry/catch, printValue: <value>. Use top-level statements withtry/catch. Input42prints: Value: 42 Inputxyzprints: Value: -1
Expected Output:
Value: 42= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.