- When you iterate through a HashSet the order is unpredictable, while a LinkedHashSet lets you iterate through the elements in the order in which they were inserted.
- LinkedHashSer uses LinkedHashMap internally, where as HashSet uses HashMap.
- LinkedHashSet is an ordered version of HashSet that maintains a doubly-linked List across all elements. Use this class instead of HashSet when you care about the iteration order.
No comments:
Post a Comment