您的位置:首页 > 博客中心 > 编程语言 >

排序比较器的方法

时间:2022-03-29 01:54

使用lambda表达式

Collections.sort(List, (a,b) ->  x1 - x2);

自定义Comparator方法

Collections.sort(List, new Comparator<E>(){
    public int compare(int a, int b){
      return a - b;
    }
});

本类排行

今日推荐

热门手游