怎麼提取出集合中的某一個元素, 並以集合的形式返回?

 從collect集合中,提取所有的元素的id:


public void test(){
List<CashDataPublicReportLineDTO> collect = result.stream().flatMap(headerDTO -> headerDTO.getLineList().stream()).collect(toList());

​​​​​​​// getScheduleLineId 爲CashDataPublicReportLineDTO 的某個屬性

List<Long> lineIds = collect.stream().map(CashDataPublicReportLineDTO::getScheduleLineId).collect(toList());
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章