← Back to Miscellaneous
Question 210
Catch StringIndexOutOfBoundsException
Catch StringIndexOutOfBoundsException
Read a word and an index on the same line. Try to printword.charAt(index). If the index is out of range for the string, print"Bad index". Usetry-catchto handleStringIndexOutOfBoundsException. ⚠️ AUTO-INPUT MODE: The input stream will automatically contain'hello 10\n'.
Expected Output:
Bad index
Topics:
Miscellaneous
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.