JAVA Comparator 重写compare方法

int compare(T o1, T o2);

接口源码描述:

Compares its two arguments for order. Returns a negative integer,
zero, or a positive integer as the first argument is less than, equal
to, or greater than the second.

翻译:有序比较它的两个参数,返回一个正数,零或者负数;当第一个参数小于,等于或大于第二个参数。

@throws NullPointerException if an argument is null and this
comparator does not permit null arguments
@throws ClassCastException if the arguments’ types prevent them from
being compared by this comparator.

翻译:此函数不允许空参数,会抛出 NullPointerException

如果参数的类型组织它们被比较器比较,会抛出 ClassCastException

2020/01/02 跟新

现在的我当然不会写这么不优雅的代码啦,附上优美的代码:


    public void test() {
   
        int[][] intervals = new int[][]{
   {
   1, 3}, {
   2, 3}</
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值