• Post Reply Bookmark Topic Watch Topic
  • New Topic

Great/Ideal use case for labels?  RSS feed

 
Forest White
Greenhorn
Posts: 8
Netbeans IDE Python VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good afternoon,

I've found several examples of how to use a label with loops to direct your break and continue targets, for example from Oracle's tutorial:

https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/java/nutsandbolts/examples/ContinueWithLabelDemo.java

But this example is just a hacked up version of the Boyer–Moore string search algorithm, which has countless examples without the labels. In fact, I have yet to encounter a problem for which I would need or even want to use a label. However, I do not consider that conclusive evidence of a fact.

Then, the question: is there an ideal or really good use case for labels in Java?

Thank you
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forest White wrote:. . . is there an ideal or really good use case for labels in Java?  . . .
I presume you have read Böhm and Jacopini (1966), so you will know there is never any absolute need for labels at all.

...except in a switch statement.

The Java™ Tutorials section you mentioned shows the Tutorials lamentably falling short of their usual quality.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!