dcsimg
Generating the hashCode for multiple keys
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Madheswaran_Rathinam
Posted On:   Thursday, February 7, 2002 03:11 AM

Hi,

I need to generate the hash-code for multiple keys. (ie., the Hash-Key contains multiple values)



(In Java) When i have a String or Integer object, i can call the method hashCode() provided by them, for getting the hash code. But i dont ve any idea, when i have an array of objects for which i need to get the hash code.



Is there any algorithm available for generating the same?



thanks in advance..

madhes

Re: Generating the hashCode for multiple keys

Posted By:   Simon_Ablett  
Posted On:   Thursday, February 7, 2002 08:32 AM

If you have an array of objects (e.g. 'String [] myObjs'). Then each element of that array is a seperate instance (that's not technically true as seperate instances could actually refer to the same object but we won't consider that here) and should have a seperate hash code. It doesn't make sense to generate a hash code for the array itself as that is merely a wrapper around the data objects. What you could do is add all of the elements together to create a master object (e.g. 'String mst = myObjs[0]+myObjs[1]+myObjs[2]') and then generate the hash on that.

Regards.

Re: Generating the hashCode for multiple keys

Posted By:   Anonymous  
Posted On:   Thursday, February 7, 2002 06:30 AM

The hashCode() method is available for all Java objects.
About | Sitemap | Contact