Search This Blog

Tuesday, May 14, 2013

Java labeled Break Statement

The break statement has two forms: labeled and unlabeled.
You can also use an unlabeled break to terminate a forwhile, or do-while loop
Unlabeled:
for(;;){
   if(){
            break; // ends this loop
       }
}


Labeled:

outer:
for(;;){
    inner:
    for(;;){
        if(){
            break inner; // ends inner loop
        } else {
            break outer; // ends outer loop
        }
    }
}



No comments: