How to clear Hashmap in java

To clear HashMap in java we use the void clear() method from Map. Using the clear method will empty the HashMap. Lets see examples on how to clear Hashmap in java. Example : C

Read More →

How to get size of HashMap

To get size of HashMap we use the int size() method provided by Map API. The size method returns the number of key/value pairs that are available in that Map. Example : Get

Read More →

How to remove elements from HashMap

To remove elements from HashMap we can use either of the 2 ways 1. Use the remove(Object key) method 2. Remove elements while iterating the HashMap Lets see some examples for both these ways 1. Use

Read More →

How to convert HashSet to ArrayList

In this post we will see examples to convert HashSet to ArrayList in java. HashSet and ArrayList are both Collection objects. Hence we can pass HashSet to the construtor of the ArrayList and get it

Read More →

How to Iterate HashSet in java

In this post we will see how to iterate HashSet in java. We can iterate HashSet either using 1. For loop 2. Iterator. We will see examples for all these methods. 1. Iterate HashSet in Java using Fo

Read More →