請問如何實現Comparator的排序
如圖,可以直接在Student.java中實現兩個接口,此時視頻中演示的Collections.sort(studentList, new StudentComparator())已不再適用。請問現在怎樣用sort方法進行排序?
希望大家多多指教,謝謝!
如圖,可以直接在Student.java中實現兩個接口,此時視頻中演示的Collections.sort(studentList, new StudentComparator())已不再適用。請問現在怎樣用sort方法進行排序?
希望大家多多指教,謝謝!
2020-03-24
舉報
2020-03-26
你是用Student類而不是StudentComparator類實現Comparator接口的,所以在sort的時候new StudentComparator()當然不適用了。?