java中的null到底是保留字还是关键字?

xiaolu_dl 2011-07-13 09:22:15
java中的null到底是保留字还是关键字?,说什么的都有,希望能给个准确答案!谢谢!
...全文
867 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Spring源码解析 2011-07-13
  • 打赏
  • 举报
回复
学习!!!!
飞跃颠峰 2011-07-13
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 xiaolu_dl 的回复:]

null和NULL有什么区别,会不会大写的不是,小写的才是,我刚刚试了,小写的回变色,大写的不会
[/Quote]

Java是大小写敏感的,大写的NULL没有任何含义,你可以把它当变量名或函数名用。小写的null代表一个空对象。
xiaolu_dl 2011-07-13
  • 打赏
  • 举报
回复
null和NULL有什么区别,会不会大写的不是,小写的才是,我刚刚试了,小写的回变色,大写的不会
xiaolu_dl 2011-07-13
  • 打赏
  • 举报
回复
答案是 B, 只有NULL不是,
龙四 2011-07-13
  • 打赏
  • 举报
回复
《Java语言规范》第三版第三章写的很明确:



3.9. Keywords
The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (§3.8):


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



所以,null,true,false不是关键字,但goto,const却是关键字
huntor 2011-07-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xiaolu_dl 的回复:]

10、如下哪些不是java的关键字?
A)const B)NULL C) false D)this E) native

那这道题你觉得该选什么?
[/Quote]
B C
huntor 2011-07-13
  • 打赏
  • 举报
回复
http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
[Quote]Java Language Keywords
Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.

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 [/Quote]
qybao 2011-07-13
  • 打赏
  • 举报
回复
java keywords

[keywords list]
  abstract boolean break byte case
  catch char class continue default
  do double else extends false
  final finally float for if
  implements import instanceof int interface
  long native new null package
  private protected public return short
  static super switch synchronized this
  throw throws transient true try
  void volatile while
  
[reserved words]
  const,goto

皮皮 2011-07-13
  • 打赏
  • 举报
回复
A 和B
const 是java 保留字
大写的NULL不是java语言的关键字>所有的关键字都是小写
qybao 2011-07-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xiaolu_dl 的回复:]
10、如下哪些不是java的关键字?
A)const B)NULL C) false D)this E) native

那这道题你觉得该选什么?
[/Quote]
B java里小写的null是关键字
zn85600301 2011-07-13
  • 打赏
  • 举报
回复
C) false
lihewei10 2011-07-13
  • 打赏
  • 举报
回复
小菜一只,不知道。。。。静观高人
xiaolu_dl 2011-07-13
  • 打赏
  • 举报
回复
10、如下哪些不是java的关键字?
A)const B)NULL C) false D)this E) native

那这道题你觉得该选什么?
五哥 2011-07-13
  • 打赏
  • 举报
回复
是的
Java中,null是一个关键字,用来标识一个不确定的对象。因此可以将null赋给引用类型变量,但不可以将null赋给基本类型变量。

51,390

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧