toSet method Null safety

Set<E> toSet ()

Creates a Set with the same elements and behavior as this Set.

The returned set behaves the same as this set with regard to adding and removing elements. It initially contains the same elements. If this set specifies an ordering of the elements, the returned set will have the same order.


Set<E> toSet();