equals()
首先看下Object中的equals(),仅简单的用==
比较两个对象
public boolean equals(Object obj) {
return (this == obj);
}
源码中对equals()的注释如下
Indicates(指出) whether some other object is "equal to" this one.
The equals method implements an equivalence(等价) relation on non-null
object references:
1. It is reflexive(自反的): for any non-null reference value
x, x.equals(x) should return true.
2. It is symmetric(对称的): for any non-null reference values
x and y, x.equals(y) should return true if and only if
3. It is transitive(传递的): for any non-null reference values
x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true.
4. It is consistent(一致的): for any non-null reference values x and
y, multiple invocations of x.equals(y) consistently(始终) return true
or consistently return false, provided no information used in equals
comparisons on the