Java Reserve Keywords

后端 未结 4 513
天命终不由人
天命终不由人 2021-01-29 02:48

Are generic, cast, and threadsafe reserved keywords in java? I am aware of the 52 keywords in java but looking for the new reserved keywor

4条回答
  •  离开以前
    2021-01-29 03:45

    Java keywords are listed in the Java language spec:

        Keyword: one of
                abstract    continue    for           new          switch
                assert      default     if            package      synchronized
                boolean     do          goto          private      this
                break       double      implements    protected    throw
                byte        else        import        public       throws
                case        enum        instanceof    return       transient
                catch       extends     int           short        try
                char        final       interface     static       void 
                class       finally     long          strictfp     volatile
                const       float       native        super        while
    

    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.

    While true and false might appear to be keywords, they are technically Boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal.

提交回复
热议问题