专业网站建设公司兴田德润简介,聊城正规网站建设设计公司,本地建网站的详细步骤,三网合一网站建设计划collectingAndThen()Java Collectors类中的方法使Collector适应于执行其他完成转换。它返回执行下游收集器动作的收集器#xff0c;然后执行附加的结束步骤。语法如下。static Collector collectingAndThen(Collector downstream, Functionfinisher)在这里#xff0c;参数T-…collectingAndThen()Java Collectors类中的方法使Collector适应于执行其他完成转换。它返回执行下游收集器动作的收集器然后执行附加的结束步骤。语法如下。static Collector collectingAndThen(Collector downstream, Functionfinisher)在这里参数T-输入元素的类型A-下游收集器的中间堆积类型R-下游收集器的结果类型RR-结果收集器的结果类型下游-收集器整理器-应用于下游收集器最终结果的功能要使用Java中的Collectors类请导入以下包。import java.util.stream.Collectors;以下是collectingAndThen()在Java中实现方法的示例。示例import java.util.List;import java.util.Collections;import java.util.stream.Collectors;import java.util.stream.Stream;public class Demo {public static void main(String[] args) {List list Stream.of(Demo1, Demo2).collect(Collectors.collectingAndThen(Collectors.toList(),Collections:: unmodifiableList));System.out.println(list);}}输出结果[Demo1, Demo2]