У меня есть простой класс Point с двумя полями типа double
. Я попросил Eclipse 3.6 создать для него equals()
и hashCode()
. Метод equals()
выглядит следующим образом:equals() generated by 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;
}
И getOuterType
выглядит следующим образом:
private Point getOuterType() {
return Point.this;
}
Так что вопрос: что цель getOuterType().equals(other.getOuterType())
линии?
у вас есть внутренний класс? – Bozho
Получается, что у меня есть, спасибо, он решен. –