ArrayIndexOutOfBoundsException when iterating through all the elements of an array

The array indexes in Java start from 0 and go to array.length - 1. So change the loop to for(int i=0;i<a.length;i++)

Leave a Comment