java List根據元素進行升序降序排序

首先實體類需要實現 Comparable 接口 實現compareTo()方法 下面是降序 如果需要升序則把位置交換一下就好了 然後調用Collections.sort(list); public static void main(String[] args) { List<Student> list=new ArrayList<Student>(); list.
相關文章
相關標籤/搜索