Your stack trace compared to the selected pattern
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array. In this case, you're trying to access a negative indexed element from the ArrayList.
Check the source of this solution for more info