Site icon NgDeveloper

How to use conditional breakpoint in eclipse (step by step)

We can say no developers in the world who developing without debugging his/her code. We have lot of debugging options to make use the debugging option more effectively.

Here we are going to see how we can debug with conditional breakpoints.
Step 1:
Below is the very simple program to explain the conditional breakpoint,

[java]
package in.javadomain;
public class ConditionalBreakpoint {
public static void main(String[] args) {
boolean value = false;
value=true;
System.out.println("Debug, if condition given in the breakpoint condition satisfies ");
}

}
[/java]

Step 2:
Put the breakpoint in the sysout line of the above program.

Step 3:
Right click on the breakpoint and click breakpoint properties (or) control+double click on the breakpoint, then click the Breakpoint properties -> Enable the Conditional checkbox -> click suspend when true radio button.
Then add the condition,

Now Run as debug and see the output for both the conditions (value==false and value==true) below,

when value==true

when value==false

Note:
After changing the breakpoint conditions, ensure you have saved it.

Recommended Java Books:

Exit mobile version