array of arraylists in java code example
Example 1: how to make an array of arraylists in java
ArrayList<Integer> [] myList = (ArrayList<Integer>[]) new ArrayList[4];
Example 2: arraylist of arraylist
public static void main(String[] args) {
ArrayList<ArrayList<Integer>> outer = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> inner = new ArrayList<Integer>();
inner.add(100);
inner.add(200);
outer.add(inner);
inner = new ArrayList<Integer>(inner);
outer.add(inner);
outer.get(0).add(300);
System.out.println(outer);
}