Index of an array starts with 0. Your array is of length 3. So the indexes of your array can be 0,1,2. In line 16, you try to access the index 3 ,which does not exist so it throws an ArrayIndexOutOfBoundsException.
lines 17,20,21 will throw ArrayIndexOutOfBoundsException for the same reason.