null 是个什么东西?? 是常量?? 关键字??

wren4255 2008-04-03 10:19:08
谢谢!!

把null看成个对象,System.out.printf(null);不行么??
...全文
470 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
rabbit_zizhu 2008-04-03
  • 打赏
  • 举报
回复
恩.java中null,false,true这些是常量,不是关键字.但也不能用它们创建标识符
对编译器来说,null是一个值.null值指引用变量没有引用堆上的任何对象.
dracularking 2008-04-03
  • 打赏
  • 举报
回复
多谢火龙果 长见识了 有空要细读这些文档
null非关键字 是和Identifiers Keywords, boolean literals等并列的null literal
  • 打赏
  • 举报
回复
An identifier cannot have the same spelling (Unicode character sequence) as a keyword, boolean literal, or the null literal.
(Excerpt from: http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8)

The null type has one value, the null reference, represented by the literal null, which is formed from ASCII characters. A null literal is always of the null type.
(Excerpt from: http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#230717)

首先,null 不是关键词;
其次,null 有一个值,即空引用

Java 中方法的传值方式基本上是按引用来传递,代码中传入 null 时,其引用的对象为空,所以会出空指针错误。
dracularking 2008-04-03
  • 打赏
  • 举报
回复
null就是无 在java中它是关键字 某种程度上可以理解为对象 因为可以赋予object reference 表示引用为空
但不是对象 不符合对象特征
这样使用null会输出NullPointerException
贝壳鱼 2008-04-03
  • 打赏
  • 举报
回复
NULL 不是对象,只是个关键字。表示未初始化的,无值的。
healer_kx 2008-04-03
  • 打赏
  • 举报
回复
null是关键字是肯定的了。其实我觉得你可以把null看成是一个带有字符串色彩的常量。
胡矣 2008-04-03
  • 打赏
  • 举报
回复
aha
suifeng0117 2008-04-03
  • 打赏
  • 举报
回复
又长了一点儿知识!支持高人讲解!
  • 打赏
  • 举报
回复
它没toString()方法 所以直接print不起来
aa321207 2008-04-03
  • 打赏
  • 举报
回复
顶起4楼
好样的
不懂编程 2008-04-03
  • 打赏
  • 举报
回复
厉害,学习
chensjmail 2008-04-03
  • 打赏
  • 举报
回复
其实你就可以把它看成是一个特殊的对象,这个对象的引用没有指向任务的内存位置
haoxiongok 2008-04-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 bao110908 的回复:]
An identifier cannot have the same spelling (Unicode character sequence) as a keyword, boolean literal, or the null literal.
(Excerpt from: http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8)

The null type has one value, the null reference, represented by the literal null, which is formed from ASCII characters. A null literal is always of the null type.
(Excerpt from:…
[/Quote]

牛牛牛,果子厉害
nihuajie05 2008-04-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 bao110908 的回复:]
An identifier cannot have the same spelling (Unicode character sequence) as a keyword, boolean literal, or the null literal.
(Excerpt from: http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8)

The null type has one value, the null reference, represented by the literal null, which is formed from ASCII characters. A null literal is always of the null type.
(Excerpt from:…
[/Quote]
西西

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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