我在 ArrayList
上看到 removeif()
,但是当我执行 stream()
时,没有任何选项。是因为 removeif()
更改了集合的大小并且流需要固定大小才能工作吗?
最佳答案
要从流中删除元素,可以使用Stream::filter
。示例:
.filter(e -> e.getId() == 4)
Is it because
removeif()
change the size of collection and stream needs a fix size to work upon ?
不,事实上流甚至可以处理无限数量的对象
关于java - 为什么removeif()在集合流上不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56678737/