Extends the Collection interface.
Interface which provides structure of the mathematical set.
Implementing classes are HashSet, EnumSet, LinkedHashSet, TreeSet.
Extending interfaces are SortedSet.
Elements can not be primitive type.
Differences between Set and List:
Set can not include duplicated elements
Set does not keep order of its elements (similar to a mathematical set)
Interface so instance can be created by using constructor of one of its subclasses.
EXAMPLE FOR DECLARATION AND USAGE:
All methods of Collection interface are available.
The of() method creates immutable Collection. It is a very fast way to declare a Set with its content for e.g. testing purposes but adding, modifying or deleting elements will be impossible.
Solution is using the constructor of the particular Set subclass on the immutable Set to make it mutable.
EXAMPLE FOR CONVERTING IMMUTABLE LIST TO MUTABLE:
EXAMPLE FOR USAGE: