I want to do something like this ArrayList<String<String>> mylist
How can I create it?
How can I add to the external and internal list
and how can I convert the internal list to a simple array list?
I want to do something like this ArrayList<String<String>> mylist
How can I create it?
How can I add to the external and internal list
and how can I convert the internal list to a simple array list?
You can go with
array.get(0) - is a internal list
This is an arraylist of arraylists holding strings.
Also
ArrayList<String<String>> mylist
makes no sense, because String is not a collection/list, but I think you understood that. Future readers might not though.See this answer to see why I chose to have
List
on the left side.Try this :
There are two ways to achieve what you desire. I am providing code snippet for both:
1.
List<List<String>> lol = new ArrayList<List<String>>();
2.
ArrayList[] set = new ArrayList[n];
The first array list isn't an array list of String, it's an ArrayList of ArrayList.