1
比方說,我有以下對象:爲什麼在執行flatmap()調用時會出現編譯錯誤?
public class DaylyData {
private Date date;
private List<Integer> numersList;
// standard getters/setters
public Map<Integer, Date> getIntToDate() {
Map<Integer, Date> resultMap = new HashMap<>();
for(Integer number : getNumersList()) {
resultMap.put(number, getDate());
}
return resultMap;
}
現在,讓我們說我有DaylyData的列表:List<DaylyData> resultList
。
什麼將是以下的結果:
resultList.stream().flatMap(entity -> entity.getIntToDate());
如果我的這個結果分配給Stream<Map<Integer, Date>>
,我越來越Type mismatch: cannot convert from Map<Integer,Date> to Stream<? extends Map<Integer,Date>>
。
在此先感謝。