内实例我该怎么办了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