When you declare an array you provide the length/size of that array.
An array starts at index 0 as you've done in your code, but you're trying to assign a value
to an index "out of bounds" - the fourth index.
new String[3] // index 0,1,2
new String[4] // index 0,1,2,3