简体   繁体   中英

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

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

条件断点

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM