Catch StringIndexOutOfBoundsException
easyQuestion 210Read a word and an index on the same line. Try to print word.charAt(index). If the index is out of range for the string, print "Bad index".
Use try-catch to handle StringIndexOutOfBoundsException.
⚠️ AUTO-INPUT MODE: The input stream will automatically contain 'hello 10\n'.
Expected output
Bad index= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
Miscellaneous
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.