Search code examples
javajls

What is the contained statement?


JLS 14.21 used in a description of a rule for unreachable statement some contained statement. To be more specific I'll cite a quote:

A while statement can complete normally iff at least one of the following is true:

  • The while statement is reachable and the condition expression is not a constant expression (§15.28) with value true.

  • There is a reachable break statement that exits the while statement.

The contained statement is reachable iff the while statement is reachable and the condition expression is not a constant expression whose value is false.

I'd suspect it's just a while's entire block statement like, for instance, the following:

while(true){
    //Something
}

That's the contained statement consist of all code enclosed by parentheses, does it?


Solution

  • The contained statement would be \\something in your example, i.e. the body of the loop. If you read JLS #14.12 the expression contained statement is used too and its meaning is possibly clearer in that context.