I have to create an ArrayList of ArrayList i.e.
ArrayList<ArrayList<Integer>> l=new ArrayList<ArrayList<Integer>>();
I will be receiving the values for the inner list at random i.e. sometimes I might get the value for the first inner list, sometimes for the second.
So, I have to do something like, l.get(x).add(y);
But since initially all the outer list variables point at null this would give me an error.
I somehow need to initialize all the outer list as an empty list []
and not null
to which I can get a valid reference.
Any idea on how to get around this problem?