Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

What does the "z:" statement mean in this class?

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have been doing fundamentals now for a year but i have not yet come across a statement like "z:"

What does z: mean here in this class?

 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a label.
You can read about it here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html
 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Pawel, interesting to see the difference between the labeled break and the labeled continue statement.
 
Sheriff
Posts: 16767
281
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be careful when you use continue and break. See my comments about them here: https://coderanch.com/t/679156/java/Add-user-inputted-names-array#3185315

In short, continue and break can be easily abused. When used in moderation and with careful consideration, these kind of jump statements are fine. However, be careful not to abuse them. The venerable GOTO statement of older programming languages got a bad reputation because it was abused so much.
 
Marshal
Posts: 74696
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is venerable the right word for goto? Even Kernighan and Ritchie don't use it in their classic book. Remember that it is always possible to write your code without using goto or any surrogates for it, including break and continue. Dijkstra wrote the Goto considered harmful article (which Junilu mentioned in the link he posted) as a letter to the Communications of the ACM; there are many places which have PDF copies of it, this being one I found on Google Scholar.

Strict avoidance of goto and its surrogates is called structured programming (probably) after the title of a book by Dahl, Dijkstra and Hoare in 1972. The concepts of structured programming are older than that; it was originally thought that avoiding spaghetti code would allow faster and more reliable software creation. Just goes to show how mistaken overoptimistic one can be.
 
Junilu Lacar
Sheriff
Posts: 16767
281
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used "venerable" to emphasize that it gets a bad rap because of misuse. Undisciplined use of GOTO is really what the issue was. If you break down flow control statements, they are really mostly conditional jumps. A GOTO is a jump. They say that Anders Hejlsberg, the architect of Turbo Pascal, Delphi, and C# could write object-oriented assembly language programs. I doubt you can do that without a lot of disciplined use of JMP instructions.
 
Junilu Lacar
Sheriff
Posts: 16767
281
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

EW Dijkstra wrote:I became convinced that the go to statement should be abolished from all "higher-level" programming languages (i.e. everything except, perhaps, plain machine code)


Even Dijkstra seems to concede that you really can't get rid of GOTO at some level of code. If you really think about it, we use GOTO all the the time, except it's hidden in more structured language constructs to protect us from a lack of discipline.

More from the essay:

The unbridled use of go to has an immediate consequence... The go to as it stands is just too primitive; it is too much an invitation to make a mess of one's program. One can regard and appreciate the clauses considered as bridling its use.



I hope nobody reading this takes it as an endorsement of GOTO in higher level languages on my part.  I agree, they are dangerous. I'm just trying to point out that whoever says they don't like GOTO really is saying they don't like undisciplined use of jump instructions because no matter how it's dressed up, whether as an if-statement or a break or a continue or while-statement or even a return statement, these are all jumps, which really boils down to a GOTO at the machine level.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic