by BehindJava

What is the load factor of Hashmap in Java

Home » java » What is the load factor of Hashmap in Java

In this tutorial we are going to learn about the load factor of Hashmap in detail.

Initial Capacity and Load Factor

HashMaps performance depends on two things i.e., first, initial capacity and second, load factor. Whenever we create Hashmap, initial capacity number of the bucket is created initially and load factor is the criteria to decide, when we have to increase the size of HashMap when its about to get full.


A load factor is the number that controls the resizing of HashMap. When a number of elements in the HashMap cross the load factor as if the load factor is 0.75 and when becoming more that 74% full then the resizing trigger which involves array copy.

How does resize happens in HashMap?

The resizing happens when the map becomes full or when the size of the map crosses the load factor. If the load factor is 0.75 and then becomes more that 75% full, then resizing trigger which involves an array copy. First, the size of the bucket is doubled, and then old entries are copied into a new bucket.

Difference between the Capacity and Size of HashMap in Java

The Capacity denotes how many times entries HashMap can store and size denotes how many mappings or key/value pair is currently present.