Redian新闻
>
Re: weird problem with hashtable--CONCLUSION
avatar
Re: weird problem with hashtable--CONCLUSION# Java - 爪哇娇娃
n*a
1
All right we are all wrong here, it's ACTUALLY a BUG in
jdk1.1.x,
try using jdk1.2.2 and the problem is gone. equals() will be
called and containsKey() will return true.
avatar
m*r
2
I think things should be like this:
When containsKey(o) is called, it calculate the o.hashCode()
and use this integer to look into the correspond position in hashtable,
get the value v and then use v.equals(o) to determine if o is in
the table.
Note: the equals method is called only ONCE.
So I think that's the answer.
Maybe actually, the key in hashtable is o.hashCode() rather than the
object o.

【在 n*****a 的大作中提到】
: All right we are all wrong here, it's ACTUALLY a BUG in
: jdk1.1.x,
: try using jdk1.2.2 and the problem is gone. equals() will be
: called and containsKey() will return true.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。