I want to create an Array that contains ArrayList elements.
I've tried
ArrayList<String> name[] = new ArrayList<String>()[];
but that doesn't seem to work.
feedback
|
You cannot create an array of a generic type. Instead, you can create an | ||||
feedback
|
The correct way is:
However, this won't work either, since you can't make an array with a generic type, what you are trying to do is a matrix, and this should be done like this:
| |||||
feedback
|
| |||
feedback
|
If you do want an array of
| |||
feedback
|
This is not proper OO and this sort of code is very implementation coupled. If you need to do such thing, probably you did something wrong. If the code is not yours, the person who made it probably did something wrong. If you know how many elements are there (or even if you didn't), why not use Map<Integer, List<String>>? | |||
feedback
|