Friday, March 13, 2009

What is the difference b/w HashSet & LinkedHashSet (JavaUtil)

Question :What is the difference b/w HashSet & LinkedHashSet? (JavaUtil)
Answer :Comment from Gyula, From the javadoc the LinkedHashSet differs from
HashSet in that it maintains a doubly-linked list running through all of its
entries. By this it preservs the order of elements when somebody iterates
over them (the elements will be retrieved in a predictable order - the order
of inserting).

No comments: