In this tutorial we are gonna learn how to copy one HashMap elements to another HashMap. We will be using putAll() method of HashMap class… [Read More]
HashMap – Get value from key example
Description Program to get value from HashMap when the key is provided. Example import java.util.HashMap; class HashMapDemo{ public static void main(String[] args) { // Create… [Read More]
Difference between HashSet and HashMap
In this article we are gonna discuss the differences between HashSet and HashMap classes. HashSet vs HashMap Differences: HashSet HashMap HashSet class implements the Set… [Read More]
Java – Get Set view of Keys from HashMap
Description Program to get the Set of keys from HashMap. Example import java.util.Iterator; import java.util.HashMap; import java.util.Set; class HashMapExample{ public static void main(String args[]) {… [Read More]
How to check if a HashMap is empty or not?
Description Program to check if a HashMap is empty or not. We are using isEmpty() method of HashMap class to perform this check. Program import… [Read More]
Clone a HashMap in Java
Description A program to clone a HashMap. We will be using following method of HashMap class to perform cloning. public Object clone(): Returns a shallow… [Read More]
Java – Check if a particular key exists in HashMap example
In the last tutorial we learnt how to check whether a particular value exists in HashMap. In this example we are gonna see how to… [Read More]
Java – Check if a particular value exists in HashMap example
In this example we are checking whether a particular value exists in HashMap or not. We will be using containsValue() method of HashMap class to… [Read More]
Java – Get size of HashMap example
In this example we are gonna see how to get the size of HashMap using size() method of HashMap class. Method definition and description are… [Read More]
Java – HashMap Iterator example
Example In the previous tutorial we have seen different-2 ways to iterate a HashMap. In this example we are gonna see how to iterate a… [Read More]
Java – Remove all mappings from HashMap example
Example In the last tutorial we shared how to remove a specific mapping from HashMap based on key. In this example we are going to… [Read More]
Java – Remove mapping from HashMap example
Example In this example we are gonna see how to remove a specific mapping from HashMap using the key value of Key-value pair. We will… [Read More]
Difference between HashMap and Hashtable
What is the Difference between HashMap and Hashtable? This is one of the frequently asked interview questions for Java/J2EE professionals. HashMap and Hashtable both classes implements java.util.Map interface, however there are… [Read More]
How to loop HashMap in java
In this tutorial we will learn how to loop HashMap using following methods: For loop While loop + Iterator Example: In the below example we… [Read More]
How to serialize HashMap in java
HashMap class is serialized by default which means we need not to implement Serializable interface in order to make it eligible for Serialization. In this… [Read More]