Order of items in HashSet not correct

前端 未结 3 1516
终归单人心
终归单人心 2021-01-28 12:13

As an exercise I am developing a simple notes application. Obviously the notes have to be saved persistently so I have the following method:

public static void s         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-28 12:37

    HashSet provides no guarantees on the order of the elements. Consider using a TreeSet if you need the elements to be ordered.

提交回复
热议问题