s-day07- Stream流中的常用方法_concat
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
package com.inmind.stream07;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stream流中的常用方法_concat
|
||||||
|
static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
|
||||||
|
合并2个流,生成一个新的流
|
||||||
|
*/
|
||||||
|
public class ConcatDemo19 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Stream<Integer> stream1 = Stream.of(1, 2, 3, 4, 5);
|
||||||
|
Stream<Integer> stream2 = Stream.of(6, 7, 8, 9, 10);
|
||||||
|
//合并2个流
|
||||||
|
Stream<Integer> stream = Stream.concat(stream1, stream2);
|
||||||
|
stream.forEach(i-> System.out.println(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user