sighol sighol - 5 months ago 10
Java Question

Create an array of ArrayList<String> elements

I want to create an array that contains ArrayList<String> elements.

I've tried

ArrayList<String> name[] = new ArrayList<String>()[];


but that doesn't seem to work.

Answer

You cannot create an array of a generic type.

Instead, you can create an ArrayList<ArrayList<String>>.

Comments