| Author |
how label work ?
|
Alvin chew
Ranch Hand
Joined: Jan 08, 2004
Posts: 834
|
|
can someone pls tell how label work and the scope of coverage by label ? is that means, if mylabel have labeled, the scope for "mylabel" label cover 2 for loop ? thank you very much for explain
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
The for statement includes the block it controls. This is one statement: for ( i = 1; i <= 10; i++ ) { sum += i; product *= i; } This is one labeled staement: myLabel: for ( i = 1; i <= 10; i++ ) { sum += i; product *= i; } The label only controls the one statement immediately following, so in your example, mylabel controls the first for statement.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
Alvin chew
Ranch Hand
Joined: Jan 08, 2004
Posts: 834
|
|
thanks mike
|
 |
 |
|
|
subject: how label work ?
|
|
|