javacollections

List doesnot have TreeList


There is a Map implementation called TreeMap and a Set implementation called TreeSet. Why is there no TreeList implementation of the List interface?

This was an interview question.


Solution

  • Basically you need to understand what is the purpose of these implementation like both these TreeMap and Treeset are implementation of SortedSet and SortedMap is used for sorting purpose but we have Collections.sort(List) which can be implied on List for sorting hence not TreeList is not required in List