了解Java中的null和'\u000'之间的区别 [英] Understanding the difference between null and '\u000' in Java

查看:2200
本文介绍了了解Java中的null和'\u000'之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一本书中阅读(由Bruce Eckel在第四版第47页的Java中思考) null 等于'\u000'。然后我想知道'\u000'究竟是什么意思。

I read in a book (Thinking in Java by Bruce Eckel, 4th edition, page 47) that null is equal to '\u000'. And then I was wondering what exactly does '\u000' really mean.

根据我的理解,null是没有什么或没有什么。 '\u000'与此定义矛盾。

As per my understanding null was nothing or absence of anything. And '\u000' comes in contradiction with this definition.

任何人都可以澄清这个问题 null '\u000'

Can anyone clarify this issue about null and '\u000'?

推荐答案

语言规范中定义了null,它表示

The language specification is where null is defined, and it says


还有一个特殊的null类型,的表达式null,没有名称。因为null类型没有名称,所以不可能声明一个null类型的变量或转换为null类型。空引用是null类型的表达式的唯一可能的值。空引用始终可以转换为任何引用类型。实际上,程序员可以忽略null类型,只是假设null只是一个可以是任何引用类型的特殊字面量。 - 文档链接(第4.1节)


null类型有一个值,null引用,由字符null表示,由ASCII字符形成。 null字面值总是null类型。 - 文档链接(第2.3节)

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. --Link to documentation (Section 2.3)

而是一个循环探测定义,但 null null引用本身 - 只是另一个指针。空引用的值不是真正相关的,并且可能是由实现者决定的,但是零或一些不能与另一个对象地址混淆的值很可能。

Rather a circular sounding definition, but the value of null is the null reference itself - just another pointer. The value of the null reference isn't really relevant and is presumably up to the implementor, but zero or some other value that can't be confused with another object address is likely.

此处可能会导致混淆,因为有一个字符值称为空字符,值为 \\\ 。这是类型char的默认值。

Confusion may be caused here because there is a character value called the null character with value \u0000. This is the default value for type char.

这篇关于了解Java中的null和'\u000'之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆