All,
I'm trying to develop a quality hashcode method based on Joshua Bloch's "Effective
Java Programming" book. I have an object who's equal method depends on two objects: a Double and a Date object. Subsequently, I believe that the hashcode method should create a hashcode based on these two objects as well. What I have so far, and this may not be correct:
I figure I can't just have result = result * 37 + date.hashCode() because might this cause an integer overfill? In look at the JDK5.0 source, I looked at the HashMap.Entry private class's hashcode method:
So...could I so something like this:
My question is this: when you're developing a hashcode based on two or more objects (not integers, doubles, etc.), what's the best way to implement this? Should I follow the example from the JDK source?
Thanks,
Dave
[ June 21, 2006: Message edited by: David Irwin ]