双型比较器

双型比较器,第1张

双型比较器

您不需要返回

double

Comparator
接口用于为要比较的元素建立排序。具有使用的字段
double
与该顺序无关。

您的代码很好。

抱歉,我错了,再次阅读问题,这是您需要的:

public class NewClass2 implements Comparator<Point> {    public int compare(Point p1, Point p2) {        if (p1.getY() < p2.getY()) return -1;        if (p1.getY() > p2.getY()) return 1;        return 0;    }    }


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5478156.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存