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]