8
looking into JDK source code of ArrayList.set(int, E) gives a hint: you need to have at least N elements in your list before you can call set(N-1, E).
Add your elements via add() method.
set(int index, E element) Replaces the element at the specified position in this list with the specified element. U should use add()
In the constructor, you have specified an initial capacity. However, the size of the list is still 0 because you have not added any elements yet.
From the documentation of ArrayList.set():
IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).