February 2014
Beginner
1248 pages
62h 25m
English
When the program encounters the invalid value 14 in the responses array, it attempts to add 1 to frequency[14], which is outside the bounds of the array—the frequency array has only six elements (with indexes 0–5). Because array bounds checking is performed at execution time, the JVM generates an exception—specifically line 19 throws an ArrayIndexOutOfBoundsException to notify the program of this problem. At this point the try block terminates and the catch block begins executing—if you declared any local variables in the try block, they’re now out of scope (and no longer exist), so they’re not accessible in the catch block.
The catch block declares an exception parameter (e) of type (IndexOutOfRangeException ...
Read now
Unlock full access