wood burning stoves 2.0*
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
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
 
 
subject: how label work ?
 
Similar Threads
Setting number of items to show in SWT List
having problems getting my Runnable Interface working
GUI- Beginner............ myWindow.getContentPane().add(myLabel)?? explain please
for Loop with y++ etc...
confusing answer