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.
我正在制作一个交易列表,每个交易都有一组数据字段,包括一个日历对象。我想根据交易日历对象中的日期将这些交易对象插入到 LinkedList 中。换句话说,按日期排序。
如何才能做到这一点?
我只给你:
Collections.sort(list, new Comparator<MyClass>() { public int compareTo(MyClass a, MyClass b) { return a.getDate().compareTo(b.getDate()); } }