Hey

marc fleury wrote:
> did you know that
> 
> byte[] byte1 = {1,2,3};
> byte[] byte2 = {1,2,3};
> 
> yields
> byte1.equals(byte2) = false;
> and
> byte1.hashCode() != byte2.hashCode();

Of course.. since you are comparing the arrays, and not their contents.
Both equals and hashCode will be the Object defaults, which work on
memory adress of the actual object.

> blows my mind man....
> 
> what is the best way to compute a byte[].hashCode()?

Iterate and add the elements together. Also depends on the distribution
of the contents. Why do you need a byte array BTW? Is this for the Xid?
Why not use an enumerated long or something?

/Rickard

-- 
Rickard �berg

Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com

Reply via email to