Last time I talked about the stream API feature in Java 8. It is a very good new feature, but unlike previously looping code, single-step debugging does not work for stream API. Luckily, IntelliJ IDEA provides a tool for us to visualize the stream code.
Example code:
1 | List<Integer> numbers2 = Arrays.asList(1, 2, 3, 4, 5, 6, 7); |
Add a break point at the last line of stream
Start debug, and find the button in debug interface
Wait for a few seconds, you can see the results of each step of the stream operation