Tips--java
Difference between "==null" and ".equals(null)"
== reference compare;
.equals() is a method;
notification: while sample = null; sample.equals(null) will throw NullPointerException.
refer topic links: topics link
Object.equals() code:
public boolean equals(Object obj) {
return (this == obj);
}
所以除非被继承类扩展,equals方法和“==”是等价了。

浙公网安备 33010602011771号