Hashset with looping

In this article, we will see how to loop Hashset in java Its very much common requirement to iterate or loop through Hashset in java applications There are mainly 2 ways to loop through Hashset in java 1) Enhanced For loop 2) Iterator Let’s see each of these ways with an example 1) Enhanced For […]

Share this article on

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
< Previous Next >