A HashMap stores key–value pairs in buckets. It uses key.hashCode() to pick a bucket, and equals() to find the right key inside that bucket. Collisions are kept in a list/tree; when the load factor threshold is exceeded it resizes and rehashes to keep average lookups near O(1).