I want to know the comparison between List and Set in terms of performance,memory allocation and usability.
If i don\'t have any requirement of keeping the uniquenes
If you don't have the requirement to have unique elements in collection simply use ArrayList
unless you have very specific needs.
If you have the requirement to have only unique elemets in collection, then use HashSet
unless you have very specific needs.
Concerning SortedSet
(and it's implementor TreeSet
), as per JavaDoc:
A Set that further provides a total ordering on its elements. The elements are ordered using their natural ordering, or by a Comparator typically provided at sorted set creation time.
Meaning it's targeted at quite specific use cases, when elements should be always ordered in a set
, which is not needed usually.