在源代码中,我忘了在链接之前添加注释.例如,以下代码:
public class HelloWorld
{
public static void main(String[] args)
{
http://www.example.com/random-link-here
System.out.println("Hello World!");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么编译?不知何故无法弄清楚它做了什么...它像Goto +评论的标签,但Java没有goto ...
该http:部分是标签后面的声明的标签.该//部分介绍了一条线评论.
通常,您会在定向break情境中看到带标签的语句,例如:
outer:
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j) {
if (someConditionThatNeedsToTakeUsOutOfBothLoops) {
break outer;
}
}
}
Run Code Online (Sandbox Code Playgroud)
......但是任何声明都可能有标签.在你的情况下,你已经标记了System.out.println("Hello World!");声明.
因为:
http: //www.example.com/random-link-here
^^^^ ^--------------------------------^
Run Code Online (Sandbox Code Playgroud)
http:是一个标签,其余的是评论
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |