Suppose there are lines А , Б , В , Я , В After adding to which collection there will be only А , Б , Б , Я ? Or write a bicycle?

    1 answer 1

    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 HashMap to Set without duplicates by keys? - Flippy
    • five
      Maybe you will enter duplicates by value? After all, the Map itself cannot contain 2 identical keys - GVArt
    • yes, exactly, by value - Flippy
    • five
      new HashSet <> (map.values ​​()) - Roman Danilov
    • 2
      @Flippy stream is useless. - Nofate