Sitemap

Member-only story

HashMap Internal Working in Java

6 min readJul 19, 2026

--

HashMap Internal Working in Java

Press enter or click to view image in full size

A HashMap stores data as Key → Value pairs

Example:

HashMap<Integer, String> map = new HashMap<>();

map.put(101, "Vinoth");
map.put(102, "Kumar");
map.put(103, "Raj");

Internally:

101  -> Vinoth
102 -> Kumar
103 -> Raj

Step 1: Create a HashMap

HashMap<Integer, String> map = new HashMap<>();

Internally, Java creates a bucket array.

Initially:

HashMap

Bucket Array

HashMap<Integer, String> map = new HashMap<>();

Default Capacity = 16 buckets
Load Factor = 0.75

Table (Bucket Array)
+---------------------------------------+
Index | Bucket |
------+---------------------------------------+
0 | -
------+---------------------------------------+
1 | -
------+---------------------------------------+
2 | -
------+---------------------------------------+
3 | -
------+---------------------------------------+
4 | -
------+---------------------------------------+
5 | -
------+---------------------------------------+
6 | -
------+---------------------------------------+
7 | -
------+---------------------------------------+…

--

--