Strange valid Java piece of code – No. 1

0
2652
Java
Java

Have you seen any strange but valid Java code? Yes? No? This is one piece I’ve seen.


static int getVal() {
    http://google.com
    ftp://google.com
    return 1;
}

If you try to compile with Java compiler, it raises no issue at all. The question is why those URIs are valid in Java syntax?
Well, in Java, there is built-in support for goto statement, and fortunately, those URIs prefix http, ftp are labels for goto statement, and the rest are comments which start with //.

While the Java 8 documentation does not introduce goto, it stills share the usage of label on branching, Java 8 Branch.