The Set interface of the Java Collections framework provides the features of the mathematical set in Java. It extends the Collection interface. Unlike the List interface, sets cannot contain duplicate elements. Since Set is an interface, we cannot create objects from it. In order to use functionalities of the Set interface, we can use these classes:
These classes are defined in the Collections framework and implement the Set interface. The Set interface is also extended by these subinterfaces:
In Java, we must import java.util.Set package in order to use Set.