gudii9
asked on
hashcode is calculated on the basis of value object
Hi,
I am reading below link
http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html
I have not understood below point
In this,hashcode is calculated on the basis of value object.Hashcode can be same for two value object so we have to implement equals() method.If equals() method return false then two objects are different.
Read more at http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html#ZZEA3viEKQ7T9uHh.99
what it mean by hashcode is calculated on the basis of value object.
Based on below example
http://www.java2blog.com/2014/07/how-hashset-works-in-java.html
I understood that india printed only once as we have not implemented hashCode and due to that hashCode different for india1 and india2 object so wont bother to check equals.
But original point (hashcode is calculated on the basis of value object) seem reverse of above concept. please advise
I am reading below link
http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html
I have not understood below point
In this,hashcode is calculated on the basis of value object.Hashcode can be same for two value object so we have to implement equals() method.If equals() method return false then two objects are different.
Read more at http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html#ZZEA3viEKQ7T9uHh.99
what it mean by hashcode is calculated on the basis of value object.
Based on below example
http://www.java2blog.com/2014/07/how-hashset-works-in-java.html
I understood that india printed only once as we have not implemented hashCode and due to that hashCode different for india1 and india2 object so wont bother to check equals.
But original point (hashcode is calculated on the basis of value object) seem reverse of above concept. please advise
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.