A collection of objects in which each object can occur only once.
A collection of objects in which each object can occur only once.
That is, for each object of the element type, the object is either considered to be in the set, or to not be in the set.
Set implementations may consider some elements indistinguishable. These elements are treated as being the same for any operation on the set.
The default Set implementation, LinkedHashSet, considers objects indistinguishable if they are equal with regard to operator Object.==.
Iterating over elements of a set may be either unordered or ordered in some way. Examples:
A HashSet is unordered, which means that its iteration order is uspecified,
It is generally not allowed to modify the set (add or remove elements) while an operation on the set is being performed, for example during a call to forEach or containsAll. Nor is it allowed to modify the set while iterating either the set itself or any Iterable that is backed by the set, such as the ones returned by methods like where and map.