Piotr Frąckowiak
Piotr Frąckowiak

Reputation: 1

Set variable value when breakpoint is hit

Is there a way to determine if Eclipse has reach the breakpoint then change the variable value?

For example

public class Test {

static boolean isDebug = false;

 static void A() {
  System.out.println(isDebug);
 }

 static void B() {
  System.out.println(isDebug);
 }

 static void C() {
  System.out.println(isDebug);
 }

public static void main(String args[]) {
 A();
 B();
 C();
}

The result would be:

false
false
false

What I need is the

static boolean isDebug = setTrueIfBreakpointWasHit;

So when if I set breakpoint on the B(); method the result would be:

false
true
true

Upvotes: 0

Views: 69

Answers (1)

Dominik
Dominik

Reputation: 1252

You can use conditional breakpoints for this. If you return false, the execution is not paused.

conditional breakpoint

Right-click on the breakpoint and select 'Properties'.

Upvotes: 1

Related Questions