Re: Hashtables
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Sep 2005 03:28:42 +0100
Roedy Green wrote:
Someone could settle this point with a program that just kept doing a toString() and hashCode on an array of objects and keep doing it to see if they ever change. (You must do something to create and discard objects to trigger GC). I expect toString() will eventually change after a GC but surely hashCode will not.
You may also see if there is a correlation between HashCode (dumped in hex) and what toString() produces which is some sort of representation of the address IIRC.
Probably.
"In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())"
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#toString()
Just checking, Object.toString will use an overridden hashCode method.
I believe IBM JRE uses a different algorithm for creating hashCodes than Sun's. Sun's are predictable (or were), although they have changed their algorithm as well.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Thomas Hawtin
- Re: Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Patricia Shanahan
- Re: Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Kenneth Patrick Turvey
- Re: Hashtables
- From: Thomas Hawtin
- Re: Hashtables
- From: Roedy Green
- Hashtables
- Prev by Date: Re: Hashtables
- Next by Date: Re: Hashtables
- Previous by thread: Re: Hashtables
- Next by thread: Re: Hashtables
- Index(es):
Relevant Pages
|