Valid indicies for an array are 0 to length - 1. For an array that has a length of 5 the last index is 4 which makes 5 out of bounds.