首页 > 试题广场 >

如下哪些是 java 中有效的关键字()

[不定项选择题]

如下哪些是 java 中有效的关键字()

  • native
  • NULL
  • false
  • this
这个关键字常见的坑:
true、false、null都不是关键字
goto、const、是保留的关键字
abstract                continue           for            new        
switch                  default            if             package     
synchronized            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
boolean                 assert 

编辑于 2017-09-16 01:43:23 回复(24)

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 (§3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (§3.10.7).

大概意思:const和goto是保留关键字。true和false看起来像关键字,但严格来说,它们是boolean常量;null看起来也像关键字,但严格来说,它是null常量。

综上,true,false,null不是关键字。而是常量。

点击查看 java se 8 官方解释

编辑于 2017-08-17 18:16:29 回复(5)
true false null都不是关键字
true false null都不是关键字
true false null都不是关键字
重点事情说3遍!   !  !
发表于 2018-10-27 19:50:25 回复(3)
java中的关键字全部都是小写的,所以NULL错误。 Java 关键字列表 所有的关键字都是小写,在MyEclipse中都会显示不同的颜色: abstract, assert,boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum,extends, final, finally, float, for, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, while
发表于 2017-08-14 23:43:18 回复(7)
常考的、不是关键字的有:
true、false、null、sizeof、friendly
发表于 2020-02-22 14:17:02 回复(0)
native竟然也是,看来是我native了
发表于 2019-02-21 21:00:32 回复(5)
A native是的
B null是的,java写成null把,NULLc++写的
C 不是 它是常量
D 是的
发表于 2017-02-10 04:11:40 回复(2)
奇怪,我选的AD,显示答案错误
发表于 2017-08-15 10:31:16 回复(0)
true、false、null都不是关键字
发表于 2022-04-09 09:06:51 回复(0)
true false null都是常量
发表于 2022-04-05 02:18:42 回复(0)
常见的坑:true、false、null都不是关键字
发表于 2021-05-27 10:50:16 回复(0)
关键字和常量不是一个概念
发表于 2017-10-12 15:49:42 回复(0)
true、false、null都不是关键字
goto、const、是保留的关键字
发表于 2021-03-07 11:04:42 回复(0)
<p>常考的、不是关键字的有: true、false、null、sizeof、friendly</p>
发表于 2020-05-17 23:00:43 回复(0)
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也不是,只是字面量。
发表于 2022-12-04 13:41:22 回复(0)
这个关键字常见的坑:
true、false、null都不是关键字
goto、const、是保留的关键字
abstract                continue           for            new        
switch                  default            if             package     
synchronized            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
boolean                 assert 
发表于 2022-10-14 21:01:23 回复(0)
true和false看起来像关键字,但严格来说,它们是boolean常量;null看起来也像关键字,但严格来说,它是null常量。 不是关键字的:true false null sizeof friendly 关键字都是小写的
发表于 2022-06-08 22:19:00 回复(0)
true false null得赋值使用
发表于 2020-09-05 18:38:11 回复(0)
注意不要跟default弄混了,我每次都是把false当作java关键字。
发表于 2019-08-14 19:37:43 回复(0)
关键字与值的区别
发表于 2024-03-25 08:33:28 回复(0)