n*****a 发帖数: 4 | 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. | m**r 发帖数: 13 | 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.
|
|