Do "separate" designations have a purpose?

I can compile and run the following code snippet, but I cannot add any additional code to it to use the designated operator. Therefore, do I correctly think that for such a statement it does not logically exist? (Java allows me to do this, which is why I ask.)

statement: System.out.print("This represents a \'standalone\' statement.");

In addition, I study Java and discovered (just for some “trivial pleasure”) that Java allows you to compile the following code snippets.

labelID: System.out.println("Label identifiers are allowed to be - ");
labelID: System.out.println("the same.");

// Labels can be "chained together", and you can "break out of" any of them.
label1:
label2:
label3: break label1;  // Can be break label1, 2, or 3.

// Labels can be associated with "null statements"
label: {}
label: ;
+4
source share
2 answers

Classic example:

outer: while (...) {
    inner: while (...) {
        if (...) break outer;
    }
}

, (lexer/parser). - . , - :)

+1

- - Java goto , Java.

goto, - Java, , .

+1

All Articles