Stream流合并的练习题
28查看
1回复
2019-07-15T16:55:25+08:00
课程问答
来自: Lambda

合并的Stream的返回值Stream出错,改成Object可以 图片描述

全部回复
import java.util.stream.Stream;

public class MergerStream {
    public static void main(String[] args) {
        Stream<Integer> stream1 = Stream.of(1, 2, 3);
        Stream<Integer> stream2 = Stream.of(4, 5, 6);
        Stream<Integer> stream3 = Stream.of(7, 8, 9);
        Stream<Integer> mergerStream = Stream.of(stream1, stream2, stream3).flatMap((i) -> i);
        mergerStream.forEach(System.out::print);
    }
}



2019-07-16T10:14:02+08:00
回复
你的回复