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