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.
In Java, we can create ArrayList by creating this simple statement: ArrayList<String> arlist = new ArrayList<String>( ); In above syntax, list is of “String” type, so the elements are that going to be added to this list will be string type. The type decide which type of elements list will have.
ArrayList of arrays can be created just like any other objects using ArrayList constructor.
You cannot create an array of a generic type.
Instead, you can create an ArrayList<ArrayList<String>>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With