Java排序(倒序)

509 阅读1分钟
public static void main(String[] args) {
    NoticeContent noticeContent1 = new NoticeContent();
    noticeContent1.setInsertTime(new Date());
    NoticeContent noticeContent2 = new NoticeContent();
    noticeContent2.setInsertTime(new Date());
    NoticeContent noticeContent3 = new NoticeContent();
    noticeContent3.setInsertTime(new Date());
    NoticeContent noticeContent4 = new NoticeContent();
    noticeContent4.setInsertTime(new Date());
    NoticeContent noticeContent5 = new NoticeContent();
    noticeContent5.setInsertTime(new Date());
    List<NoticeContent> noticeContents = new ArrayList<>();
    noticeContents.add(noticeContent3);
    noticeContents.add(noticeContent5);
    noticeContents.add(noticeContent4);
    noticeContents.add(noticeContent1);
    noticeContents.add(noticeContent2);
    Collections.sort(noticeContents,Collections.reverseOrder());

// ,Collections.reverseOrder() System.out.println(""); }