|
Array subscript is out of bounds.
int array [] = new int [20]; // This sentence creates an array of 20 ints with subscripts from 0-19;
for (int i = 2; i <21; i ++) {// When the execution reaches i = 20, the conditions are still met, and an exception will be reported when the array [i] is referenced
You can change to int array [] = new int [21];
Or for (int i = 0; i <20; i ++) |
|