Skip to main content

Posts

Showing posts from April, 2020

HashMap in Java | How HashMap internally works | Performance of HashMap

In this tutorial, we are going to learn how HashMap works internally.This is a very popular java interview question from the collection framework and been asked so many times to check candidates understanding on Map collection. If you want video explanation then go through this : Let’s suppose A hashmap is a storage place where we want to keep all of the data. So building upon this, we might want to add data, retrieve data or manipulate data, right? We’ll go through all of this by understanding the structure of the HashMap Java Class. `public class java.util.HashMap<K, V> {}` What does this mean? It says, that a HashMap (A storage place) will store the data in the form of a key-value pair where K is key and V is value. Why key-value, you’d ask? So this is because it makes the retrieval of data easier. What a hashmap does is, it takes the data and store the data in a bucket and then label that bucket with the hash of the key. So when we want that data back, w