我想知道断点有多少次被击中。Java - 断点多少次?
问题提出:对于前4个点击中的每一个,记下currentMin的值,当前的最大值和中间值,可以在调试器中看到。
我的值是:n = 40,currentMin = 0,currentMax = 40,mid = 20。
这四个命中?或者我需要使用上述值四次循环四次?
public class Breakpoint {
public int breakp() {
int n = 40;
int currentMin = 0;
int currentMax = n;
while (currentMin < currentMax) {
int mid = (currentMin + currentMax)/2;
if (mid * mid + mid + 1 <= n)//breakpoint is on this line {
currentMin = mid;
} else {
currentMax = mid;
}
}
return currentMin;
}
public static void main(String[] args) {
Breakpoint b = new Breakpoint();
int a = b.breakp();
System.out.println(a);
}
}
我觉得这是一个有点混乱,因为该类也叫“断点” 。我假设问题指向你的while循环中的某个断点? – phatfingers 2012-08-11 15:48:54
对不起忘了添加断点放在第5行和n的值为40 – nsc010 2012-08-11 15:51:13