In the source code I forgot to add comment before the link. For example, the following code:
public class HelloWorld
{
public static void main(String[] args)
{
http://www.example.com/random-link-here
System.out.println("Hello World!");
}
}
Why it compiles? Somehow unable to figure out what it does... Its like label for Goto + comment, but Java does not have a goto...
The http: part is a label labelling the statement that follows. The // part introduces a line comment.
Normally you see labelled statements in directed break situations, like:
outer:
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j) {
if (someConditionThatNeedsToTakeUsOutOfBothLoops) {
break outer;
}
}
}
...however any statement may have a label. In your case you've labelled the System.out.println("Hello World!"); statement.
Because :
http: //www.example.com/random-link-here
^^^^ ^--------------------------------^
http: is a label and the rest is a comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With