package com.shrimpking.t3;
import java.util.stream.Stream;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/11 16:08
*/
public class PeekStream
{
public static void main(String[] args)
{
Stream<Integer> stream = Stream.of(3,1,-5,-2,2);
stream.filter(e -> e > 0)
.peek(x -> System.out.println("Filtered value:" + x))
.limit(3)
.peek(y -> System.out.println("Limited value:" + y))
.forEach(z -> System.out.println("foreach:" + z));
}
}
PeekStream
原创
©著作权归作者所有:来自51CTO博客作者虾米大王的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:FlatMapStream
下一篇:MapStream
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章