How to implement this method for my own classes used as key in a HashMap.
Thanks.
Printable View
How to implement this method for my own classes used as key in a HashMap.
Thanks.
You need to return an integer that will satisfy these two conditions:
(1) for any particular object in the class, your method will always return
the same value.
(2) for different objects in the class, your method should have a good
chance of returning different values.
PC2
"Joseph Berdat" <jberdat@eim.ch> wrote in message
news:3b24d543@news.devx.com...
> How to implement this method for my own classes used as key in a HashMap.
> Thanks.
>
>
"Joseph Berdat" <jberdat@eim.ch> wrote:
>How to implement this method for my own classes used as key in a HashMap.
>Thanks.
>
>
The book 'Effective Java' by Josh Bloch explains in detail the contract of
equals() and hashCode() and give excellent guidelines and examples on how
to implement them. This chapter is available online somewhere on the SUN
site.