在Java中单独行中指定的URL不会发出编译时错误。为什么? [英] A URL specified in a separate line in Java doesn't issue compile-time errors. Why?

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

问题描述

有些日子,我错误地在我的Java程序中错误地粘贴了一个URL,我试图运行该特定程序,并且在我的好奇心中,它成功运行,没有任何警告,没有错误,也没有例外。类似的代码如下所示。我编译并成功运行。

Some days age, I mistakenly pasted a URL in my Java program in a hurry, I attempted to run that specific program and in my curiosity, it ran successfully with no warnings, no errors and no exceptions. The similar code is as shown below. I compiles and runs successfully.

final public class Main
{
    public static void main(String[] args)
    {                    
        System.out.println ("A curiosity");
        https://localhost:8181/OnlineShoppingCartSystem-war/Restricted/Home
        System.out.println ("compiled Ok!");
    }
}

在main()方法的第二行,它应该发出一些编译时错误但它运行良好并在控制台上显示相应的消息。为什么?

At the second line within the main() method, it should issue some compile-time errors but it works well and displays the respective messages on the console. Why?

推荐答案

令牌 https:被解释为标签。接下来的 // 开始一个换行符。因此,发布的代码仍然是有效的Java(如果您注意到语法着色)。

The tokens https: gets interpreted as a label. And the // that follows starts a new-line comment. So, the posted code continues to be valid Java (if you notice the syntax coloring).

这篇关于在Java中单独行中指定的URL不会发出编译时错误。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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