I have a condition like this
List<String> mainList = new ArrayList<String>();
for(int i=0; i<3; i++){
mainList = getList();
}
private static List<String> getList() {
List<String> listName = new ArrayList<String>();
listName.add("String");
return listName;
}
As mainList is getting List<String> in return and mainList itself a list of Strings. How can I keep updating mainList with those strings in listName returning from method.
If you give any solution will that also apply on Maps?
To append a list to an existing list use the
addAllmethod:For
Mapyou haveputAll: