1

I've read some tutorials which using this syntax in Java, but I don't know what it's mean?

newNumber:while (1 <= 500) {
  // do something
}

I don't understand what newNumber:while mean and I can't find it on oracle documentation.

  • 2
    https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html – JB Nizet Aug 19 '18 at 12:26
  • Whoever originally wrote `newNumber:while` is poor coder. Keywords should always have space around them. Conventionally, a label appears on a line by itself. I’ve seen it placed on the same line as the start of a loop, but omitting the space after the `:` is obnoxious, and serves no purpose other than to look L33T by writing code that’s deliberately harder to understand. – VGR Aug 19 '18 at 16:00

1 Answers1

0

newValue is label here. You can use it with break and continue statement. It becomes relevant for nesting loops when you want to jump from inside the nested loop.

AlexR
  • 114,158
  • 16
  • 130
  • 208