Sometimes when you are debugging your program in Eclipse you will be using breakpoints within program loops. What can be really frustrating is when this loop is really large and the particular iteration you are interested is hundreds of iterations away.
Assume we are debugging the following program and we are only interested in stepping through the for loop when i==500.
The two most common naive approaches would be to step through the loop 500 times by pressing the green arrow 500 times, or you could add an if conditional statement directly into the code and shift the breakpoint onto this conditional.
However the first approach will give you repetitive strain injury and the second approach will make a mess of your code.
If you select your breakpoint in the breakpoints view in Eclipse you will see that a panel with options becomes visible for that particular breakpoint. You can select hit count, and add a numerical value into the text field. This means the breakpoint will be ignored this many times before being suspended again.
Another option is to enter in a conditional statement. Below the “Choose a previously entered condition” drop down, you should see a text area (You may need to make the view a bit bigger to see it). This text area is free text so you can enter anything you wish, although the debugger will complain if you enter in variables that don’t exist.
Now when this breakpoint is visited AND this condition is true, the breakpoint will be suspended.