SyntaxFix
Write A Post
Hire A Developer
Questions
I draw your attention to the ArrayList.add documentation, which says it throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
ArrayList.add
IndexOutOfBoundsException
index < 0 || index > size()
Check the size() of your list before you call list.add(1, object1)
size()
list.add(1, object1)