【发布时间】:2012-09-21 14:01:29
【问题描述】:
如何在 Eclipse 中启用 Notch 在this video 中所说的“运行时调试”?
作为测试,我希望能够编辑以下代码的输出,并在其运行时将其更改为“Hello Runtime Debugging”。
public class HelloWorld {
public static void main(String[] args) throws InterruptedException {
doIt();
}
private static void doIt() throws InterruptedException {
for (int i = 0; i < 1000; ++i) {
System.out.println("Hello World " + i);
Thread.currentThread().sleep(100);
}
}
}
编辑:我修改了代码,现在我得到了我想要的结果。 Suraj Chandran 下面的回答对此进行了解释。
private static void doIt() throws InterruptedException {
for (int i = 0; i < 1000; ++i) {
print(i);
Thread.currentThread().sleep(100);
}
}
private static void print(int i) {
System.out.println("Hello Sir " + i);
}
【问题讨论】: