Possible Duplicate:
How is hashCode() calculated in Java
I found there’s no implementation in hashCode() method of root class Object in Java:
public native int hashCode();
If I have an Object a and an Object b, how can I know the a.hashCode() and b.hashCode() value without using System.out.println()? Just by the hashCode implementation.
I have try to new two ArrayList objects and to my big surprise the hashCode() values are the same: both of them are 1.
hashCodeis anativemethod which means that a system library is called internally. See Java Native Interface for more details.There is a question on SO Why hashCode() and getClass() are native methods? Might be interesting for you.