LinkedHashSet Methods Flashcards
1
Q
Compare between Hashset , LinkedHashSet and TreeSet
A
HashSet doesn’t maintain any kind of order of its elements.
LinkedHashSet maintains the insertion order. Elements gets sorted in the same sequence in which they have been added to the Set.
TreeSet sorts the elements in ascending order.
2
Q
Declaring a LinkedHashSet
A
LinkedHashSet lhset = new LinkedHashSet();
3
Q
Adding element to LinkedHashSet
A
lhset.add(“Element”);