This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how label work ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how label work ?" Watch "how label work ?" New topic
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
 
Consider Paul's rocket mass heater.
 
subject: how label work ?