• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • 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?

 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thank you Pawel, interesting to see the difference between the labeled break and the labeled continue statement.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56597
172
  • Mark post as helpful
  • send pies
  • 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: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!