如何将java.util.Map转换为fastutil.BigList?
BigList<Employee> empList= empMap.values().stream().collect(Collectors.toList());
发布于 2018-10-25 06:04:31
我看到BigList是一个扩展java.util.Collection的接口。您可以使用Collectors.toCollection来收集这种类型。
您必须选择一个实现BigList接口的特定类。例如:
BigList<Employee> empList =
empMap.values()
.stream()
.collect(Collectors.toCollection(ReferenceBigArrayBigList::new));当然,如果您希望创建的BigList实现有一个接受Collection的构造函数,您可以自己实例化它并将empMap.values()传递给它,而无需使用Stream。
https://stackoverflow.com/questions/52982266
复制相似问题