Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


IDEA Debug Stream 流

IDEA Debug 大约 705 字

示例代码

public class StreamDemo {

    public static void main(String[] args) {
        List<Integer> list = Stream.of(1, 2, 3, 4, 5).filter(integer -> integer > 3).collect(Collectors.toList());
        System.out.println(list);
    }

}

步骤

  1. Stream代码行下断点,可选择LineLambdaAll。(Line:不会进入filter等操作符,Lambda:只进入filter等操作符,All:两者都进入)
  2. 点击Debug面板的Trace Current Stream Chain进入Stream Trace流追踪面板。
  3. 刚进入Stream Trace面板时会显示Evaluation in process正在计算中,计算完成显示结果面板。
  4. Stream面板显示:可查看流中对象及个数。
  5. filter面板:左边显示Stream流对象,中间使用连接线连接,右边显示过滤后对象及个数。
  6. collect面板:左边显示过滤后的对象,右边显示聚合后的对象及个数。
  7. 点击左下角Flat Mode可参看Stream - filter - collect完整过程。

示意图

IDEA debug Stream.png

相关视频

https://www.bilibili.com/video/BV1oG411t7WH

https://www.ixigua.com/7131729593785909764

阅读 1462 · 发布于 2022-08-08

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批