How can I create an Array of ArrayLists?

As per Oracle Documentation:

“You cannot create arrays of parameterized types”

Instead, you could do:

ArrayList<ArrayList<Individual>> group = new ArrayList<ArrayList<Individual>>(4);

As suggested by Tom Hawting – tackline, it is even better to do:

List<List<Individual>> group = new ArrayList<List<Individual>>(4);

Leave a Comment