Post a Job  |   Ask a Question?   |   Already registered? login or register
25/11/2016 10:46 PM

How it is possible to have same hashCode for two different data.

Spam    2 Comments

25/11/2016 23:36:26
In this case the hashCode() method of String class will returns the same hashcode it's just a coincidence becoz hashcode() internaly performs some calculation based on whatever content you are passing and then it will multiply with prime number(any) and returns it.... according to my knowledge it's just a coincidence where the two diff content calculated with the prime number and the result become same there could be some more pair of content(maybe)...

27/11/2016 01:46:51
In this case i can not say, But generally, if you not implement a good hash algorithm in hashCode() method then there will be chance to get same hashCode with different data.

Languages :