So you fill the large array with 20 elements. In the if statement. if int i is less that half of the larger.length/2 (which equals 10th index) fill the small1 array. The else statement throws an array index out of bound. ;/