Tim Cooke wrote:The line with the 'start' label is reachable.
I meant that the start: label can never be reached by a break or continue statement.
Daniel Cox wrote:Never mind. After doing some googling, I found out that any Java statement (except a declaration) can be labelled. I guess it provides an alternative way to comment your code. However, the most common use of labels is their use in break and continue statements.
Do not use labels to comment your code, the comment syntax (//) (/**/) is much better for doing that.
Yes, labels can be combined with break and continue statements, but only use them when trying to break out of nested loops and switches. Some would argue that even using labels in this way, while syntactically correct, is equivalent to the frowned upon GOTO, and that alternatives should be used instead.