Caused by: java.lang.IndexOutOfBoundsException: Index: 4, Size: 3 at java.base/java.util.ArrayList.rangeCheckForAdd(ArrayList.java:788) at java.base/java.util.ArrayList.add(ArrayList.java:513) code example
Example: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 at java.util.ArrayList.add(ArrayList.java:483)
//if Your arrayList is empty. its crashing
yourlist.add(1,"data");
//you can use this code
yourlist.add("data");