"immediately completes normally" 对 if 语句意味着什么?
What does "immediately completes normally" mean for the if statement?
"immediately completes normally"是否意味着 if 语句实际上已被绕过并且其条件未被评估?
编辑:
为了理解 Java 规范中与 if 语句相关的短语 iteself,我特意省略了一个示例。
但似乎没有人在这种情况下考虑过这个短语。
这是一个演示程序。
import java.io.*;
class TestBreakWIthLabel
{
public static void main (String[] args) throws java.lang.Exception
{
int x = 1;
L:if ( x++ < 2 ) break L;
System.out.println( "x = " + x );
}
}
但是有人会提供他 "explanation" 对程序的看法是个坏主意。我想独立于程序示例了解该短语的含义。
这是规范(14.15 中断语句)中的相应引用。
A break statement with label Identifier attempts to transfer control
to the enclosing labeled statement (§14.7) that has the same
Identifier as its label; this statement, which is called the break
target, then immediately completes normally. In this case, the
break target need not be a switch, while, do, or for statement.
假设您指的是 this part of the JLS
A break
statement with label Identifier
attempts to transfer control
to the enclosing labeled statement (§14.7) that has the same
Identifier
as its label
; this statement, which is called the break
target, then immediately completes normally. In this case, the break
target need not be a switch
, while
, do
, or for
statement.
其中 break
目标是一个 if
语句,那么封闭的标记语句是 if
语句并且它的条件已经被评估,因为你在它的主体中,其 包含声明 。它不会在 完成 时再次评估。
"immediately completes normally"是否意味着 if 语句实际上已被绕过并且其条件未被评估?
编辑:
为了理解 Java 规范中与 if 语句相关的短语 iteself,我特意省略了一个示例。
但似乎没有人在这种情况下考虑过这个短语。
这是一个演示程序。
import java.io.*;
class TestBreakWIthLabel
{
public static void main (String[] args) throws java.lang.Exception
{
int x = 1;
L:if ( x++ < 2 ) break L;
System.out.println( "x = " + x );
}
}
但是有人会提供他 "explanation" 对程序的看法是个坏主意。我想独立于程序示例了解该短语的含义。
这是规范(14.15 中断语句)中的相应引用。
A break statement with label Identifier attempts to transfer control to the enclosing labeled statement (§14.7) that has the same Identifier as its label; this statement, which is called the break target, then immediately completes normally. In this case, the break target need not be a switch, while, do, or for statement.
假设您指的是 this part of the JLS
A
break
statement withlabel Identifier
attempts to transfer control to the enclosing labeled statement (§14.7) that has the sameIdentifier
as itslabel
; this statement, which is called thebreak
target, then immediately completes normally. In this case, thebreak
target need not be aswitch
,while
,do
, orfor
statement.
其中 break
目标是一个 if
语句,那么封闭的标记语句是 if
语句并且它的条件已经被评估,因为你在它的主体中,其 包含声明 。它不会在 完成 时再次评估。