在计算 rep 值之后,需要在 System.out.println(Répulsion:" + rep); 处放置条件断点,然后在执行停止于该行,则拖放到帧"以再次执行该方法.您还应该使用 Double.isNaN(rep)或 rep.isNaN(),而不是 rep == Double.NaN .I have this Java Code in Eclipse that I would like to Debug.This is the code : public Double repulsion(Node n1, Node n2) { Double rep = 0.0; rep = Math.pow(K, 2) / distEuc(n1, n2); System.out.println("Répulsion : " + rep); listForcesRep.add(rep); return rep;} private Double distEuc(Node n1, Node n2) { Double d = 0.0; Object[] n1Attributes = n1.getAttribute("xy"); Double x1 = (Double) n1Attributes[0]; Double y1 = (Double) n1Attributes[1]; Object[] n2Attributes = n2.getAttribute("xy"); Double x2 = (Double) n2Attributes[0]; Double y2 = (Double) n2Attributes[1]; d = Math.sqrt((Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2))); return d;}I toggled a breakpoint at line : rep = Math.pow(K, 2) / distEuc(n1, n2); and I ran the debugger in its default values and it works fine.The thing is that at some point the rep variable takes a value NaN and I need a conditional breakpoint in order to understand why.I set the conditional breakpoint like this :But when I run the debug, it skips the breakpoint and the loop keeps on going.What did I do wrong? And how can I fix it?Thanks! 解决方案 That's because rep is still equals to 0.0 in that line: Double rep = 0.0;You need to put a conditional breakpoint at System.out.println("Répulsion : " + rep);, after calculating rep value, then when execution stops at that line, you "Drop to Frame" to execute again that method.You should also use Double.isNaN(rep) or rep.isNaN() instead of rep == Double.NaN. 这篇关于Eclipse调试器不会在条件断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 21:05