This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I know you normally don't see labeled breaks outside of if statements but it came up on a test. What I don't really understand is there a purpose for them? If I try to do anything after the break you get a compile error "unreachable statement." For example:
If you uncomment out the here2 print stmt you'll get a compile error. So my question is what is the point of ever having a labeled break in an if statement if you can't have anything after the labeled break? [ February 02, 2002: Message edited by: Rick Reumann ]
Rick, yeah that's somewhat weird... You know that Java has no goto statement unlike C/C++. Such a break statement can be used to achieve the same behavior as a goto in C/C++. The fact that the compiler objects to the unreachable statement (here2) is pretty normal since that statement is in fact unreachable. HIH