【问题标题】:My java code has an obvious error. Why does it compile and run?我的 java 代码有一个明显的错误。为什么它会编译和运行?
【发布时间】:2010-12-08 08:23:38
【问题描述】:
public class HelloWorld {
    public static void main (String args[]){
        System.out.println ("Hello ");
        http://www.google.com
        System.out.println ("World!");
    }
}

上面的代码只是编译和执行正常。为什么编译器没有报错?

【问题讨论】:

    标签: java syntax


    【解决方案1】:

    http: 是 Label Statement。另见here。

    //www.google.com 部分随后被解释为// 注释。

    【讨论】:

      【解决方案2】:

      因为http:它认为它是标签,然后其余部分在评论中

      标签的基本用法:

      label1:
      for(){
        label2:
        for(){
            if(condition1)
            break label1;//break outerloop
      
            if(condition2)
            break label2;//break innerloop
        }
      }    
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-06
        • 2017-03-27
        • 2013-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多