while循环的continue指令未执行

Continue instruction of while loop not executed

while循环中的continue指令没有被执行。 在 Eclipse 调试中,循环在 System.out.

之后中断

任何人都知道可能导致此问题的原因,有没有办法在 cpu 指令级别进行调试以查看会发生什么?

  do { // recursive calls through element.parents() until the formula pattern (patternFormula) matches
                counter++;
                System.out.println(counter);
                lookupElement = lookupElement.parent();

                String s = replaceArrowTagAndClean(lookupElement.html()); // replace <img .. src=> and return text()

                m = patternFormula.matcher(s);
                if( (found = m.find()) ) {
                    oneMoreLookahead = false;
                    System.out.println("Continue " + counter);
                    continue;
                }
            } while(!found || oneMoreLookahead);

            System.out.println("End");

输出为:
1
2
3
4
继续 4
结束

(抱歉,创建这个 post 时遇到了一些麻烦。哈哈)

指令continue将跳过循环中的所有后续代码行,并进入下一次迭代。

如果将 continue 放在循环代码的最后一行,则保留或删除该指令的行为是相同的。

在你的情况下,你可以简单地使用 break 指令立即退出循环。