Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
日付の配列リストがあり、日付の昇順と降順で並べ替えたいと考えています。誰でもこれの完全なコードスニペットを提供してもらえますか? このような質問をたくさん見てきましたが、適切な答えが見つかりませんでした。
リストはこのようになります
List<Date> dates= new ArrayList<Date>();
どんな種類の助けも大歓迎です、どうもありがとう、
すでに Comparable を実装しているためDate、次を簡単に使用できます。
Date
Collections.sort(dates);
昇順、降順でソートするには:
Collections.sort(dates, Collections.reverseOrder());