gpt4 book ai didi

java - 命中断点时设置变量值

转载 作者:行者123 更新时间:2023-12-01 09:27:01 26 4
gpt4 key购买 nike

有没有办法确定 Eclipse 是否已到达断点然后更改变量值?

例如

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();
}

结果将是:

false
false
false

我需要的是

static boolean isDebug = setTrueIfBreakpointWasHit;

所以当我在 B() 上设置断点时;方法的结果将是:

false
true
true

最佳答案

您可以为此使用条件断点。如果返回 false,则不会暂停执行。

conditional breakpoint

右键单击断点并选择“属性”。

关于java - 命中断点时设置变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39754596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com