Sorted List in java like TreeMap or SortedSet

Lol*_*lly 5 java collections

Do we have sorted list in java just like SortedSet or TreeMap ? I have a class having one of the property as List of objects. This list has to be sorted at any time when adding or when setting it through setters (set(List list)).

Do we have any component like TreeMap for list ? Any suggestions or help will be really appreciable. Thanks in advance.

Bhe*_*ung 8

列表的目的是它们应该保持添加它们的元素的顺序.所以,我不认为你想要的是什么.

您可以随时使用Collections.sort()方法对列表进行排序.