作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
第一个声明有效,但第二个声明不正确,为什么?
java.util.Arrays.asList(1,2,3,4,5).stream()
.map(n -> n+1)
.collect(Collectors.toList());
List<Integer> list = IntStream.rangeClosed(1, 10)
.map(n -> n + 1)
.collect(Collectors.toList());
错误:
Type mismatch: cannot convert from Collector<Object,capture#5-of ?,List<Object>>
to Supplier<R>
最佳答案
虽然有一个collect
Stream
上的方法它接受 Collector
, IntStream
上没有这样的方法.
您可以转换您的 IntStream
到 Stream<Integer>
使用 boxed()
方法。
关于java流收集函数给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46418821/
我有一个经典的 ASP 页面 (VBscript),它在服务器端生成 XML,然后 Response.Writes。该页面根本没有客户端。 但是我需要将其转换为 JSON。由于我找不到有效的 ASP
我想从客户端应用程序的 HDFS 中读取特定的 SequenceFile。我可以使用 SequenceFile.Reader 来做到这一点,它工作正常。但是是否也可以通过分析抛出的 IOExcepti
我是一名优秀的程序员,十分优秀!