Java
HashSet add() Method in Java
The add(E element) method of HashSet inserts the specified element into the set. It returns false if the set already contains the specified element otherwise returns true. Syntax Parameters e is the element to insert into set Program 1 Output Set elements: [50, 20, 40, 10, 30] Program 2 Output Read more…