Suppose there are lines А , Б , В , Я , В After adding to which collection there will be only А , Б , Б , Я ? Or write a bicycle?
|
1 answer
HashSet , TreeSet and LinkedHashSet are part of the Set family. In Set sets, each element is stored in only one instance, and different Set implementations use a different order of element storage.
- And if, say, you need to translate
HashMaptoSetwithout duplicates by keys? - Flippy - fiveMaybe you will enter duplicates by value? After all, the Map itself cannot contain 2 identical keys - GVArt
- yes, exactly, by value - Flippy
- fivenew HashSet <> (map.values ()) - Roman Danilov
- 2@Flippy stream is useless. - Nofate ♦
|