Tôi có điểm lớp đơn giản với hai trường loại double
. Tôi đã hỏi Eclipse 3.6 để tạo ra equals()
và hashCode()
cho nó. Phương pháp equals()
trông như thế này:bằng() được tạo bởi Eclipse: getOuterType()?
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point other = (Point) obj;
if (!getOuterType().equals(other.getOuterType()))
return false;
if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
return false;
if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
return false;
return true;
}
Và getOuterType
trông như thế này:
private Point getOuterType() {
return Point.this;
}
Vì vậy, câu hỏi là: Mục đích của getOuterType().equals(other.getOuterType())
dòng là gì?
bạn có lớp học bên trong không? – Bozho
Nó chỉ ra rằng tôi có, cảm ơn, nó được giải quyết. –