在 Java 中的 equals(Object o) 方法中,我可以访问传入对象的私有变量,而无需通过其公共 getter。
public boolean equals(Object o){
...
MyObject other = (MyObject)o;
return getProp() == other.prop;
}
怎么样?
在 Java 中的 equals(Object o) 方法中,我可以访问传入对象的私有变量,而无需通过其公共 getter。
public boolean equals(Object o){
...
MyObject other = (MyObject)o;
return getProp() == other.prop;
}
怎么样?