HashCode value of String class Object!
The hashCode() function of a String Class Returning the Same hashcode value for the equal strings.I think hashCode is the Decimal representation of Objects Hexadecimal memory address.But,if i compare the two equal strings with if statement as follows
if(s1==s2) //say s1=new String("Hello");s2=new String("Hello");
It returns the false;because the two Strings are at two different memory locations.
How the String Class is Calculating the "hash-code" for its Objects?How it is printing the same "hash-code" value for two equal strings,though both are at two different memory locations?Is it not calculating the hash-code value based on the Objects memory address?If so,What exactly the magic behind returning the same "hash-code" value for two equal strings even though both are at two different locations?Its urgent please reply it.