How to debug Java 8 streams in Intelij IDEA?

How to debug Java 8 streams in Intelij IDEA? All intermediate calls are lazy and are executed during a terminal operation, so it makes no sense to wrap methods on separate lines. I haven't yet been able to get the idea to show the elements of the stream at some step other than the start and end. System.out. println arrange-somehow unprofessional, are there other ways out of the box?

Author: TheSN, 2016-11-23

2 answers

Starting from version 2017.3, IDEA has a Stream Debugger built in.

enter a description of the image here

You can activate it when the debugger stopped on the stream:

enter a description of the image here

Stream Debugger visualizes each step of the stream, clearly showing the filtering and transformation of elements:

enter a description of the image here

 2
Author: fori1ton, 2019-02-14 09:28:48

I think the best thing is to put a Breakpoint with conditions. You can set the conditions of the intermediate function.

  1. Creating A Breakpoint
  2. set conditions on a variable or variables
  3. debag will stop at the specified location under the specified conditions

Something like this

enter a description of the image here

 0
Author: Saidolim, 2016-11-23 15:16:58