andbin
21-03-2007, 10:15
Vorrei avere una conferma di una cosa che riguarda l'uso di break con etichetta:
Il Java Language Specification dice:
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 while, do, for, or switch statement. A break statement must refer to a label within the immediately enclosing method or initializer block. There are no non-local jumps.
Cioè dice che il target può anche non essere un while/do/for/switch. Quindi cosa può essere? Ci ho pensato un attimo ... può essere anche un if, un blocco {} o un try. Giusto?? O mi son dimenticato qualcosa?
Il Java Language Specification dice:
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 while, do, for, or switch statement. A break statement must refer to a label within the immediately enclosing method or initializer block. There are no non-local jumps.
Cioè dice che il target può anche non essere un while/do/for/switch. Quindi cosa può essere? Ci ho pensato un attimo ... può essere anche un if, un blocco {} o un try. Giusto?? O mi son dimenticato qualcosa?