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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Declaring a LinkedHashSet

A

LinkedHashSet lhset = new LinkedHashSet();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Adding element to LinkedHashSet

A

lhset.add(“Element”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly