|
On the first iteration of the for loop, i=1 and j=3. During the while loop, j is incremented. At the end of the while loop, i=j (which is now 4) and j becomes 2*i+1 (9). In the second while loop, the statement array[i]=array[j] causes the exception because j is 9. I could be wrong though.
|