19 1 5 -1 27
The method requires that its parameters contain correct data. The following will not work:
operate.printRange( ar1, 1, 10 );
There are only eight elements of ar1
.
If you asked to print elements 1 through 10 you would see:
19 1 5 -1 27 19 5 java.lang.ArrayIndexOutOfBoundsException
When the method tries to access the non-existing 8th element, the program throws an exception. Here is the method, again, with some new blanks:
The new version of the method makes sure that index
is zero or greater, and is less than the length of the array.
Complete the new, improved method.