โ Back to Exceptions
Question 656
List Index Out Of Range
List Index Out Of Range
AList<int>holds{ 5, 10, 15 }. Read an index and printlist[index]. Unlike an array, theList<T>indexer throws anArgumentOutOfRangeExceptionfor a bad index; catch it and printBad index. Use top-level statements withtry/catch. Input2prints: 15 Input9prints: Bad index
Expected Output:
15
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.