How to debug for loop after skipping some loop of it

Viewed 333

How can I debug a loop! I have a loop of 50000 count and want to debug the end of it. I have to press F8 for it 50000 time to get the end result. How can I do by skipping the 49900 loop and directly go to last loop by debugging! Thanks

 for (int i=0;i<50000;i++)
    // some code;
2 Answers

You can do it with a conditional breakpoint.

First, put a breakpoint at the line where you want to debug. After that, right-click on that breakpoint, so the following window will appear: enter image description here

Now you can specify at which point you want to trigger this breakpoint, in your case, it would be: enter image description here

Now you can run your app with the debugger attached.

More info here: https://www.jetbrains.com/help/idea/using-breakpoints.html

I usually use if block with break point into loop.

for (int i = 0; i < 50000; i++) {
    if (i == 49900)
        Log.d("1","1"); // break point here

    // do stuff
}
Related