sighol sighol - 1 year ago 75
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 Source

You cannot create an array of a generic type.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download