CJCoding With Joseph
15per day

Catch StringIndexOutOfBoundsException

Read 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
Topics:
Miscellaneous
📥 Auto-Input:
hello 10\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.