Java
HashSet clear() Method in Java
The clear() method of HashSet removes all the elements from the HashSet. The HashSet becomes empty after the call to the clear() method. Syntax Parameters It does not take any parameter and does not return anything. Return Value It does not return anything. Program 1 Output Set elements before clear: Read more…