• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Great/Ideal use case for labels?

 
Greenhorn
Posts: 8
Netbeans IDE Python VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic