Differences in terms:
1. = is to judge whether two variables or instances point to the same memory space equals is to judge whether the values of the two variables or the memory space pointed to by the instance are the same
2. = means to compare the memory address equals () is to compare the content of the string
3. = whether the guidance is the same equals () indicates whether the value is the same
I have always been familiar with this ··
So, find some summary of others ··
The purpose is to learn.
"=" What is an equal sign operation "=" or an equal sign operation is a binary operator in Java programming language, used to compare Native types and objects. For native types such as Boolean, Int, and float, use "=" to compare the two. However, when comparing objects, it will be confused with equals. "=" Compares two objects based on memory references. If the two objects have identical references (pointing to the same object), the "=" Operation returns true; otherwise, false. What is the equals method equals () method defined in the object class, according to the specific business logic to define this method, used to check the equality of two objects. For example, two employees are considered equal. If they have the same empid, you can rewrite the equals method in your own domain object to compare which two objects are equal. Equals and hashcode have contracts (whenever you override the equals method, you also need to override the hashcode () method ), the default equals method is the same as the "=" operation. rewriting the equals method based on business needs is one of the best practices. It is not surprising that equals and compareto are consistent, so that when the stored object is in the treemap or treeset set, the compareto method is used to check equality, and the behavior is consistent.
Equals and =