By default-double equals = =, the memory address is compared. -Equals (), the memory address is compared by default. -Hashcode (), the default is to return the memory address of object. The way in which the method is rewritten in string often encounters situations where you need to override Equals () and hashcode (), such as a string that rewrites both methods. The implementation of the string Equals () is to first determine whether the memory space of two strings is consistent and then compare each character. The implementation of String Hashcode () is *31 to each character and then accumulates. The contract for Equals () and Hashcode () has a contract in Java:-If two objects are equal, i.e. equals () returns True, their hashcode () must be equal. -but if the hashcode () of two objects is equal, the two objects (judged by Equals ()) are not necessarily equal. For example, when accessing key-value pairs in HashMap, these two methods are used:-Using hashcode () to calculate the position of the entry in the array-the likelihood of collisions, that is, multiple entry hash code is the same, there is the same "lattice"-at this point, you need to use equals () to determine if the key is identical in general, the override of Equals () and hashcode () is bound to occur because the contractual relationship is guaranteed. Reference-http://www.cnblogs.com/xudong-bupt/p/3960177.html-http://www.importnew.com/8701.html
Java double equals sign, Equals (), Hashcode () Summary