內實例我該怎麼辦了Java 8個流做Java的8個流
for (List<Category> parentPath : getPathsInternal(parent, controlSet)) {
if (!(parentPath instanceof LinkedList)) {
parentPath = new LinkedList<Category>(parentPath);
}
parentPath.add(category);
result.add(parentPath);
}
內實例,我不知道如何用Java編寫8個流等功能。任何方向?
if (!(parentPath instanceof LinkedList)) {
parentPath = new LinkedList<Category>(parentPath);
}
你知道lambda可以是多行,對不對?他們可以包括你想要的任何陳述? –
我可以做getPath ... Stream()。forEach(....所有邏輯..)但我想看到更好的方式,這可能是可能的 –
在99%的所有'LinkedList'用法中,它是錯誤的選擇。另外1%無論如何都需要重新設計一個完整的應用程序。那麼,爲什麼你要將非'LinkedList'轉換爲'LinkedList's,爲什麼你要做*有條件的*?是否「有時修改源代碼」真的是你想實現的目標? – Holger