[英]Java Reserve Keywords
java 中是generic
、 cast
和threadsafe
保留關鍵字嗎? 我知道 java 中的 52 個關鍵字,但正在尋找新的保留關鍵字列表。
請在此處查看此鏈接。 這是Java 6的保留關鍵字列表。
abstract continue for new switch
assert (c) default goto (a) package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum (d) instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp (b) volatile
const (a) float native super while
(a) not used
(b) added in 1.2
(c) added in 1.4
(d) added in 5.0
所以,不,你列出的這三個詞都不在保留集中。
此關鍵字列表也可以在第 3.9 節的 Java 語言規范中找到。
Java 關鍵字列在Java 語言規范中:
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
關鍵字
const
和goto
是保留的,即使它們當前沒有被使用。 如果這些 C++ 關鍵字錯誤地出現在程序中,這可能允許 Java 編譯器生成更好的錯誤消息。雖然
true
和false
可能看起來是關鍵字,但它們在技術上是 Boolean 文字。 同樣,雖然null
可能看起來是一個關鍵字,但從技術上講,它是 null 文字。
根據Oracle 文檔generic
, cast
, threadsafe
不是保留 Java 關鍵字。
到目前為止,java 中只有 50 個關鍵字。 下面列出了這些
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if 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
* not used
** added in 1.2
*** added in 1.4
**** added in 5.0
關鍵字const
和goto
是保留的,即使它們當前沒有被使用。 true
、 false
和null
可能看起來像關鍵字,但它們實際上是文字; 您不能將它們用作程序中的標識符。
請參考http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.