I have a data structure of the following form:
HashMap<Integer, ArrayList<ArrayList<Integer>>> map = new HashMap<Integer, ArrayList<ArrayList<Integer>>>();
// I am trying to add a new list inside the map's value if the value is already present in the hash.
while(//some condition){
if(!map.containsKey(//some value)){
ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
map.put(//some value, list);
ArrayList<Integer> currentList = new ArrayList<Integer>();
currentList.add(1); currentList.add(2);
map.get(//some value).set(map.get(//some value).size(), currentList);
}
else{
ArrayList<Integer> currentList = new ArrayList<Integer>();
currentList.add(1); currentList.add(2);
map.get(//some value).set(map.get(//some value).size(), currentList);
}
}
But this throws up an error saying IndexOutOfBoundsException at Index: 0 and Size: 0