有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (3) 个答案

  1. # 1 楼答案

    保留以备将来使用

    这样,如果将来需要这个关键字,就不会有使用它们的源代码,也不会有代码被破坏

    例如,如果java保留了单词in,java 5中的enhanced for loop介词可以写成:

    for( int i in someInts ) { 
    }
    

    但既然不是这样,我们有:

    for( int i : someInts ) { 
    }
    

    相反(顺便说一句,我觉得这样更好)

  2. # 2 楼答案

    Java Language Specification开始:

    The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.

    (我想这句话已经出现在第一版了。)

  3. # 3 楼答案

    有时文字是为了将来的目的而保留的。这里很可能就是这种情况