Treemap methods

The TreeMap class has various methods that are used to operate the data of TreeMap. We have already discussed how to create a TreeMap in java. Here we will see how to put, get, iterate, and remove the element from TreeMap. Here is the table content of the article will we will cover this topic.How … Read more

Difference between HashMap and LinkedHashMap

The HashMap and LinkedHashMap are the most widely used collection in java. Both are very popular to store the object based on key-value pairs. But both have some similarities and differences also. Here we will discuss the difference between HashMap and LinkedHashMap. So let’s find the HashMap vs LinkedHashMap. Difference between HashMap and LinkedHashMap 1. … Read more

Difference between hashmap and ConcurrentHashMap

We have learned about HashMap and ConcurrentHashMap in java. Both are the most popular concepts of Java. But HashMpa was introduced in JDK 1.2 and ConcurrentHashMap introduced in 1.5. So it is the most common question for an interview What is the difference between hashmap and Concurrenthashmap? and What is the need of Concurrenthashmap in … Read more

ConcurrentHashMap in java

We have learned about HashMap in java and how does it work internally. As we have seen HashMap doesn’t support multithreading.  To support multithreaded environment to HashMap, Java provides ConcurrentHashMap in java that is part of the Concurrency Collection Classes. The ConcurrentHashMap is used in a multi-threaded environment to avoid ConcurrentModificationException. Here is the table content … Read more

How to iterate hashmap in java

Like other collections, we can’t directly traverse map in java. To iterate hashmap in java we can use the HashMap iterator() method and java map foreach() method. In this post, we will see how to Iterate a HashMap in Java. As we already know HashMap stores data in form of entry and each entry is … Read more