[英]In the queue I have implemented below the students are displayed from oldest to newest.I want to display inserted students from the newest to oldest
[英]If TreeSet arranges data from oldest to newest which class orders them from newest to oldest
我在筆記應用程序中有以下代碼。 注釋按鍵排序。 TreeSet將最舊的放在首位。 我想相反。 使用哪個班級?
//retrieve data, map unordered data collection with a key and a value
Map<String, ?> notesMap = notePrefs.getAll();
//get a list of all the keys of the notes, keySet-return all Keys without order, TreeSet-sorts data
SortedSet<String> keys =new TreeSet<String>(notesMap.keySet());
您可以定義自己的Comparator
,其行為與默認情況相反。 然后在各種容器的構造函數中傳遞它的實例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.