萍聚社区-德国热线-德国实用信息网

 找回密码
 注册

微信登录

微信扫一扫,快速登录

萍聚头条

查看: 638|回复: 0

1-1-19-23 请问null和""有什么差别?

[复制链接]
发表于 2003-2-7 01:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册 微信登录

x
发信人: flyyi (伊烟), 信区: Java      
标  题: Re: 请问null和""有什么差别?
发信站: BBS 水木清华站 (Tue Jul 23 20:07:30 2002)

《effective java》。
null表示不存在对对象的引用,而""表示空字符串,存在引用,也就是说存在指向""的“
指针”。
String中的equals()方法似乎不能用null作为参数。这是jdk1.3doc 的内容:

public boolean equals(Object anObject)Compares this string to the specified ob
ject. The result is true if and only if the argument is not null and is a Stri
ng object that represents the same sequence of characters as this object.

应该用!=来比较。
【 在 tainy 的大作中提到: 】
: 哦?请指教
: 我记得那本著名的effective java programming(似乎是这个名字)
: 里面不推荐用捕获异常代替逻辑流程。
: 再说,上面的用法我也没发现多此一举啊,请说明一下好吗?呵呵
: 【 在 ooww (白皮) 的大作中提到: 】
: : 但似乎这是推荐的做法啊
: : 而且这里判断多此一举啊
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
您需要登录后才可以回帖 登录 | 注册 微信登录

本版积分规则

手机版|Archiver|AGB|Impressum|Datenschutzerklärung|萍聚社区-德国热线-德国实用信息网

GMT+1, 2025-2-7 12:41 , Processed in 0.057030 second(s), 16 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表