initialize 2d arraylist java code example
Example: creating a 2d arraylist in java
List<List<String>> listOfLists = new ArrayList<List<String>>(size);
for(int i=0; i<size; i++) {
listOfLists.add(new ArrayList<String>());
}
List<List<String>> listOfLists = new ArrayList<List<String>>(size);
for(int i=0; i<size; i++) {
listOfLists.add(new ArrayList<String>());
}