package com.zjl.stream;
import java.util.ArrayList;
import java.util.stream.Stream;
public class Stream合并方法concat {
public static void main(String[] args) {
ArrayList<String> strings = new ArrayList<>();
strings.add("张无忌");
strings.add("周芷若");
strings.add("赵敏");
strings.add("张强");
strings.add("张三丰");
strings.add("张三丰");
ArrayList<Integer> integers = new ArrayList<>();
integers.add(10);
integers.add(20);
Stream<String> stringStream = strings.stream();
Stream<Integer> integerStream = integers.stream();
Stream<Object> all = Stream.concat(stringStream, integerStream);
all.forEach(ereryOne -> System.out.println(ereryOne));
}
}
运行结果:
|