Java / Set and its implementations
Why do we need LinkedHashSet while we already have HashSet and TreeSet?
HashSet does not maintain order and returns random order every time we retrieve elements.In TreeSet elements are naturally sorted but there is increased cost associated to it.
LinkedHashSet maintains the order of elements without incurring increased cost.
LinkedHashSet is introduced in JDK 1.4 while HashSet and TreeSet are introduced in JDK 1.2.
More Related questions...