为什么Java中的HTTP URL会编译? [英] Why does a HTTP URL in Java compile?

查看:76
本文介绍了为什么Java中的HTTP URL会编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你有这样的程序:

public class ABC
{
    public static void main(String args[])
    {
        System.out.println("1");
        http://example.com
        System.out.println("2");
    }
}

注意URL http: //example.com 写在两个输出语句之间。

Note the URL http://example.com written in between the two output statements.

为什么程序编译没有任何错误?

Why does the program compile without any errors?

推荐答案

程序无错误编译的原因是程序将 http:视为标签,这在Java中是允许的,并且主要用于循环。

第二部分,即 // example.com 是评论,由于 // ,因此被编译器忽略。

The reason the program compiles without error is that the program considers http: as a label, which is allowed in Java, and is mostly used with loops.
The second part, i.e., //example.com is a comment, due to the //, and is therefore ignored by the compiler.

因此它可以正确编译。

这篇关于为什么Java中的HTTP URL会编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆