Help the world stop coronavirus! Stay home!

Prev Next

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.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Queue and its implementations

Comments & Discussions