I have the following code:
List<List<String>> allData= getData()
if (allData== null)
allData= new ArrayList<ArrayList<String>>();
// populate allData below
Now I want to initialize allData
but I get Type mismatch: cannot convert from ArrayList<ArrayList<String>> to List<List<String>>
. What is the correct way I can initialize this?
It is not possible to return ArrayList<ArrayList<String>>
from getData()
Thanks!
allData = new ArrayList<List<String>>();
or - even simpler - let type inference do its job:allData = new ArrayList<>();