//Creating HashSet
HashSet<String> set = new HashSet();
//adding elements
set.add("One");
set.add("Two");
//Removing element);
set.remove("One");
//Removing all the elements available in the set
set.clear();
// Set implementation using HashSet
Set<String> animals = new HashSet<>();
Set<T> mySet = new HashSet<>();
A Set is a Collection that cannot contain duplicate elements.
The Set interface contains only methods inherited from Collection
and adds the restriction that duplicate elements are prohibited.
public E set(int index, E element)
//The set() method of
//java.util.ArrayList class is used to replace the
//element at the specified position in this list with
//the specified element.