突然产生一个疑问:Java
中 null
是关键字吗?
于是我google
了一下:
这些博客为什么都长一样暂且不讨论,就这个权重第一的答案我认为有问题。为了严谨些,在官方文档中寻求答案往往是最可靠的:1
While true and false might appear to be keywords, they are technically boolean literals (§3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (§3.10.7).
官方文档说了,人家只是看起来像,但是并不是,true
、false
也不是,只是字面量。
附正经的关键字们:
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