Take the tour ×  I'm busy studying for my certification and I
stumbled upon a concept I've never even heard before - "Labeled
Statements". e.g:  'label' : 'statement'  L1: while(i < 0){
L2: System.out.println(i);  So my question is.. why? How is this
useful and when would one want to use something like this?
share|improve this question add comment  6 Answers  up vote 20
down vote accepted  The only use that I'm aware of is that you
can use labels in break or continue statements. So if you have
nested loops, it's a way to break out of more than one level at
a time:  OUTER: for (x : xList) {           for (y : yList) {
// Do something, then:               if (x > y) {
// This goes to the next iteration of x, whereas a standard
// "continue" would go to the next iteration of y
continue OUTER;  As the example implies, it's occasionally
useful if you're iterating over two things at once in a nested
fashion (e.g. searching for matches) and wa