Today I will share with you a little trick in the IDEA debugging process.
Let's talk about the scenario first. Have you ever encountered a similar situation, in a loop structure, a certain situation in the middle may go wrong. For example, in the result of the following code, there may be a problem when it is executed for the 27th time.
for(int i = 0; i < 100; i++) {
// 业务逻辑
System.out.println(i);
}
So at this time, how would you debug it? Is it possible to add a breakpoint like the following
Then madly click the small green arrow, to the one that goes wrong in the future?
In fact, there is a function in IDEA that can add conditions to breakpoints, so that it doesn't have to be so troublesome.
The operation is also very simple, just right-click the red point of the breakpoint that has been added, and a form will pop up with the item condition, as shown below:
Here you can enter the condition that you want this breakpoint to take effect. For example, if I enter i == 27 here, then when the loop executes to i equal to 27, the program will stop.
That way, you don't need to run through crazy dots to keep him skipping to the stage of the loop you want.
Of course, conditional breakpoints can be used not only in loops, but also in many complex debugging scenarios.
That's all for today's sharing. If this little trick is useful to you, please like, watch, share, follow, and support it!
Welcome to my public account: Programmer DD. Learn about cutting-edge industry news for the first time, share in-depth technical dry goods, and obtain high-quality learning resources
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。