s-day07--使用Lambda表达式简化有参数有返回值的方法(比较器)
This commit is contained in:
@@ -18,12 +18,14 @@ public class Demo02 {
|
||||
);
|
||||
System.out.println("排序之前:"+students);
|
||||
//sort方法排序
|
||||
Collections.sort(students, new Comparator<Student>() {
|
||||
/*Collections.sort(students, new Comparator<Student>() {
|
||||
@Override
|
||||
public int compare(Student o1, Student o2) {
|
||||
return o2.score-o1.score;
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
Collections.sort(students,(Student o1, Student o2)->{return o1.score-o2.score;} );
|
||||
|
||||
System.out.println("排序之后:"+students);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user