-
implement int hashCode()
How to implement this method for my own classes used as key in a HashMap.
Thanks.
-
Re: implement int hashCode()
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.
>
>
-
Re: implement int hashCode()
"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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks