Collections.sort()를 사용하여 점의 List<Point2D>
을 정렬하려고합니다. 나는이 비교기를 올바르게 설정했다고 생각한다. 어쨌든, 오류 메시지는 The method sort(List<T>, Comparator<? superT>) in the type Collections is not applicable for the arguments (List<Point2D>, new Comparator<Point2D.Double>(){})
입니다. 아무도 왜 내 컴파일러가이 오류를 던지고 이해합니까?Point2D Comparator가 오류를 던지고
Collections.sort(points, new Comparator<Point2D.Double>() {
public int compare(Point2D.Double p1, Point2D.Double p2) {
return Double.compare(p1.getX(), p2.getX());
}
});
당신이 Point2D''의 목록이있는 경우 다음 Point2D''에 대한 비교가 필요합니다. 현재 당신은 'Point2D.Double'에 대한 비교기가 동일하지 않습니다. – Turamarth