CJCoding With Joseph
15per day

Nested Try-Catch

Write a program that reads a string. Use nested try-catch blocks:
- The **outer** try-catch parses the string as an integer. If it fails, catch NumberFormatException and print "Outer: not a number".
- Inside the outer try, the **inner** try-catch accesses arr[index] where arr = {5, 10, 15}. If that fails, catch ArrayIndexOutOfBoundsException and print "Inner: index out of bounds".
- If both succeed, print the element.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '1\n'.

Expected Output:

10
Topics:
Miscellaneous
📥 Auto-Input:
1\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.