|
-
Aug 14th, 2006, 06:45 AM
#1
Thread Starter
PowerPoster
[RESOLVED] What is a " label "?
Hi ….
Can you explain what is a label, which is used with loops, with the following example?
I found it from a book. But still can't understand this code.
boolean found = false;
outer: for(int row=0; row<10; row++)
{
inner: for(int col=0; col<10; col++)
{ // some code which may change found to true
if(found)
{
break outer; // jumps to outer loop
}}}
-
Aug 14th, 2006, 08:27 AM
#2
Frenzied Member
Re: What is a " label "?
A label allows you to break out of a certain loop. If you have three loops nested and you want to break out of the outermost loop, then how is the compiler suppose to know what loop to break out of?
A normal break statement simply looks like this:
-
Aug 14th, 2006, 02:41 PM
#3
Re: What is a " label "?
 Originally Posted by System_Error
A label allows you to break out of a certain loop. If you have three loops nested and you want to break out of the outermost loop, then how is the compiler suppose to know what loop to break out of?
A normal break statement simply looks like this:
That's very correct.
But in addition: The label is the physical address of command, you can consider it "a Name" for the following line.
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Aug 14th, 2006, 10:41 PM
#4
Thread Starter
PowerPoster
Re: What is a " label "?
Thanks for your comments.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|