IntelliJ IDEA has actually been supported for Java 8 Stream
debugging, which has not been used much before. Today IntelliJ IDEA demonstrates how to debug the Stream
chain calls in Java 8.
Stream code:
String[] words = new String[]{"Hello", "World"};
List<String> collect1 = Arrays.stream(words)
.map(e -> e.split(""))
.flatMap(Arrays::stream)
.distinct()
.collect(Collectors.toList());
set a breakpoint on the first line, then enter debug mode. When the breakpoint enters, click Trace Current Stream Chain
button:
then it will automatically enter the current Stream
tracking debugging window, which will show the tabs of each chained call. Click each TAB to see the tracking results of each step.
can also click Flat Mode
to enter Flat Mode and display all tracking results at once:
OK, very convenient!