Code Room
Code reviewMediumcr-g270
Subject Sign errorsLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Java bucketing helper that maps an object to one of `n` buckets.

`hashCode()` can return any 32-bit int, and `n` is the bucket count (e.g. 16).

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
class BucketMap<V> {    private final List<List<V>> buckets;    private final int n;     BucketMap(int n) {        this.n = n;        this.buckets = new ArrayList<>(n);        for (int i = 0; i < n; i++) buckets.add(new ArrayList<>());    }     int bucket(Object key) {        return key.hashCode() % n;    }     void put(Object key, V value) {        buckets.get(bucket(key)).add(value);    }}
Run or narrate your approach, then ask the coach.