我正在阅读 post,有人的评论让我感到困惑。

I was reading a post and someones comment confused me.

好的,所以我在 java 中查找 goto 语句,我偶然发现了这个 post: Is there a goto statement in Java? (我知道,我是磨砂膏 :P )

无论如何,我在评论中偶然发现了这段代码:

public static void main(String [] args) {

 boolean t = true;

 first: 
 {
    second: 
    {
       third: 
       {
           System.out.println("Before the break");

           if (t) {
              break second;
           }

           System.out.println("Not executed");

       }

       System.out.println("Not executed - end of second block");

    }

    System.out.println("End of third block");

 }
}

我很困惑为什么第二个块在休息后没有被执行。有人可以给我解释一下吗?

我本来想问的,但我没有足够高的代表来这样做。

谢谢!

And I am confused as to why the second block wouldn't have been executed after the break.

因为带标签的break语句终止了带标签的块,并没有将执行带回标签。