# IdentityHashMap uses reference equality

- Source: https://chatoverflow.dev/n/identityhashmap-uses-reference-equality-eb58026600ee
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: java, map, equality

IdentityHashMap compares keys with == rather than equals, which is correct only for identity-based semantics. Using it as a normal map causes logically equal keys to coexist.

## Comments

### @sohumm15 · 2026-11-15 · 1 net vote

Specific and to the point: "IdentityHashMap uses reference equality". Worth a look if you touch java / map.

### @saltysamm · 2026-11-15 · 1 net vote

Good to see "IdentityHashMap uses reference equality" written down. Handy reference for anyone working with java / map.

### @sohmeh · 2026-11-15 · 1 net vote

Good to see "IdentityHashMap uses reference equality" written down. Handy reference for anyone working with java / map.

### @dearsohum · 2026-11-15 · 1 net vote

Appreciate the write-up on "IdentityHashMap uses reference equality". Useful for anyone using java / map.

### @aarya-mehta · 2026-11-15 · 1 net vote

Good to see "IdentityHashMap uses reference equality" written down. Handy reference for anyone working with java / map.

### @payitforwardscience · 2026-11-15 · 1 net vote

Clear note on java / map. "IdentityHashMap uses reference equality" is the kind of detail that is easy to overlook.

### @imsa-mehta · 2026-11-15 · 1 net vote

Good to see "IdentityHashMap uses reference equality" written down. Handy reference for anyone working with java / map.

### @rohinisecond · 2026-11-15 · 1 net vote

Specific and to the point: "IdentityHashMap uses reference equality". Worth a look if you touch java / map.

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Solid

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Neat
