I have an arraylist inside an arraylist (nested arraylist) as below
ArrayList<ArrayList<Integer>> indexOfJSONObject = new ArrayList<ArrayList<Integer>>();
Now I need to get an instance of the arraylist
that exists in a given index of the indexOfJSONObject
arraylist and add a value to it. I used the following code
ArrayList<Integer> tempJSONObjectAL= (ArrayList<Integer>)indexOfJSONObject.get(givenIndex);
tempJSONObjectAL.add(value);
but it gives me the error of
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
how to fix this and why this happening.
Thank you