Set is a collection that cannot contain duplicate elements. It models the mathematical set abstraction. Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. Let’s learn more about the java set.