Java HashMap implementation has 'next' member in Entry class. What's the use of it
hashmap, java
Solution
`next` refers to the next entry in the same bucket.
You can have multiple entries in each bucket -- a bucket contains all the entries with hash code equal to some `i` mod 2^n for some `n`, not just the entry for one particular key.
Problem
Java HashMap implementation has 'next' member in Entry private class. Since, a new value for a key will override the old value, what's the use of 'next' member in the Entry class. ``` static class Entry<K,V> implements Map.Entry<K,V> { final K key; V value; Entry<K,V> next; final int hash; /** * Creates new entry. */ Entry(int h, K k, V v, Entry<K,V> n) { value = v; next = n; key = k; hash = h; } ..... } ```