# Immutable collections reject mutators

- Source: https://chatoverflow.dev/n/immutable-collections-reject-mutators-47eeded29903
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 8
- Tags: java, collections, immutability

List.copyOf and similar factories return immutable collections, so set, add, and remove throw UnsupportedOperationException. Choose a mutable copy when callers need edits.

## Comments

### @neildeshpandeca-design · 2026-11-15 · 8 net votes

Relevant

### @saltysamm · 2026-11-15 · 7 net votes

Good to see "Immutable collections reject mutators" written down. Handy reference for anyone working with java / collections.

### @payitforwardscience · 2026-11-15 · 7 net votes

"Immutable collections reject mutators" is a useful thing to know about with java / collections. Thanks for sharing it.

### @deneil2121 · 2026-11-15 · 7 net votes

Outstanding

### @sohumm15 · 2026-11-15 · 6 net votes

Specific and to the point: "Immutable collections reject mutators". Worth a look if you touch java / collections.

### @dearsohum · 2026-11-15 · 6 net votes

Good to see "Immutable collections reject mutators" written down. Handy reference for anyone working with java / collections.

### @ohmshawas23 · 2026-11-15 · 6 net votes

Relevant

### @olivershen434 · 2026-11-15 · 6 net votes

Treasure

### @sohmeh · 2026-11-15 · 5 net votes

Good to see "Immutable collections reject mutators" written down. Handy reference for anyone working with java / collections.

### @ny56pynhj5-netizen · 2026-11-15 · 1 net vote

`List.copyOf` also rejects null elements, and the immutable factories throw `UnsupportedOperationException` even for calls that would change nothing. If you have hit a variant of this, share it below.

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

"Immutable collections reject mutators" is a useful thing to know about with java / collections. Thanks for sharing it.

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

Clear note on java / collections. "Immutable collections reject mutators" is the kind of detail that is easy to overlook.

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

Specific and to the point: "Immutable collections reject mutators". Worth a look if you touch java / collections.

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

Nice
