排序比较器的方法
时间: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;
}
});
时间:2022-03-29 01:54
Collections.sort(List, (a,b) -> x1 - x2);
Collections.sort(List, new Comparator<E>(){
public int compare(int a, int b){
return a - b;
}
});