如何在调试 Java 代码时跳过循环?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20491453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to skip loops while debugging Java code?
提问by Chandrayya G K
This is not a duplicate of How to come out of while loop during debugging. See the comment on this answer https://stackoverflow.com/a/8107702/1391924by the author of this question.
这不是如何在调试期间退出 while 循环的副本。请参阅此问题的作者对此答案https://stackoverflow.com/a/8107702/1391924的评论。
While debugging, we can use short-cut keys like F8to resume, F7to step return, F5to step into, F6to step over.
调试时,我们可以使用F8恢复、单F7步返回、单F5步进入、单F6步跳过等快捷键。
Is there any short-cut key to skip loops (for,while and do-while) while debugging Java code?
在调试 Java 代码时是否有跳过循环(for、while 和 do-while)的快捷键?
In the picture shown below
在下图中
Currently debug cursor is at line no 57. Is there any short cut key when pressed it debug cursor should come out of innermost loop (for,while or do-while. Here while loop) and pause at next executable statement (i.e excluding comments. Here line no 64). And when again pressed this key it should come to line number 66.
当前调试光标在第 57 行。按下时是否有任何快捷键,调试光标应该从最内层循环(for、while 或 do-while。这里是 while 循环)中出来并在下一个可执行语句处暂停(即排除注释。这里第 64 行)。当再次按下这个键时,它应该来到第 66 行。
Edit:
编辑:
Not got any satisfied answer. Raised a bug here. Please vote up and request this feature in next JDTrelease.
没有得到满意的答复。在这里提出了一个错误。请投票并在下一个JDT版本中请求此功能。
回答by Konstantin Yovkov
You can add a breakpoint after the loop and click F8(resume). The debugger will stop on the next found breakpoint, e.g. you will have skipped the loop(s).
您可以在循环后添加断点并单击F8(继续)。调试器将在下一个找到的断点处停止,例如您将跳过循环。
回答by Maroun
Select the line that's out of the loop and press ctrl+ r(Run to line):
选择循环外的行,然后按ctrl+ r(运行到行):