Java label irregularity (possible bug?)

后端 未结 1 499
夕颜
夕颜 2021-01-12 04:22

If we look at the Java standard §14.7, we see that statements may have label prefixes, e.g.:

LabeledStatement:

     Identifie

相关标签:
1条回答
  • 2021-01-12 04:55

    The expression

    int k = 3; 
    

    is a local variable declaration statement.

    The statement used in the syntax of a label statement

    LabeledStatement:

      Identifier : Statement

    does not contain local variable declaration statements. You therefore can't use them within a labeled statement directly.

    Local variable declaration statements can be used within blocks which can be used within labeled statements.

    0 讨论(0)
提交回复
热议问题