使用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;
}
});
2024-02-27 22:57:45
Collections.sort(List, (a,b) -> x1 - x2);
Collections.sort(List, new Comparator<E>(){
public int compare(int a, int b){
return a - b;
}
});