如果您有这样的程序:
public class ABC
{
public static void main(String args[])
{
System.out.println("1");
http://example.com
System.out.println("2");
}
}
Run Code Online (Sandbox Code Playgroud)
请注意在http://example.com两个输出语句之间写入的URL .
为什么程序编译没有任何错误?
所以我已经看到很多情况,其中标签被用于for循环,特别是双嵌套循环.
这是唯一可以使用它们的情况吗?还是有其他我不知道的常见用途.我觉得它是一个我从未使用过的java工具!
在源代码中,我忘了在链接之前添加注释.例如,以下代码:
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 ...
以下程序编译成功并运行没有任何错误.根据我的理解,第4行应该抛出错误.有人可以解释一下吗?
class Test{
public static void main(String args[]) {
// my favorite website is
http://www.stackoverflow.com/questions/ask
System.out.println("hello world");
}
}
Run Code Online (Sandbox Code Playgroud)