如何将Java8 IntStream收集到Deque中界面? 我可以像这样使用 List 执行这种操作:
List<Integer> integerList = IntStream.of(1, 2, 3)
.boxed()
.collect(Collectors.toList());
最佳答案
您无法收集到接口(interface),而是通过 Collectors.toCollection
收集到它的实现(只要它是 Collection
)
Deque<Integer> d = IntStream.of(1, 2)
.boxed()
.collect(Collectors.toCollection(ArrayDeque::new));
关于collections - 将Java8 IntStream收集到Deque接口(interface)中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50411630/