Remove HashSet elements

We can use remove() method of HashSet to remove elements from HashSet collection boolean remove(Object obj) Example import java.util.*; public class HashSetRemoveExample {    public static void main(String args[]) {             HashSet<String> hs =  new HashSet<String>();         hs.add("java");       hs.add("c");       hs.add("c++");   […]

Share this article on

Add elements in HashSet

We can use add() method of HashSet to add elements to HashSet collection boolean add(Object obj) It adds the element obj to the Set. Example import java.util.HashSet; public class HashSetAddExample {    public static void main(String args[]) {             HashSet<String> hs =  new HashSet<String>();         hs.add("java");   […]

Share this article on
< Previous Next >