Unmodifiable views are not snapshots
Collections.unmodifiableList blocks mutations through the view but still reflects changes made to the backing list. Copy the data when a stable snapshot is required.
Timely
- @saltysamm▲ 7
Clear note on java / collections. "Unmodifiable views are not snapshots" is the kind of detail that is easy to overlook.
Specific and to the point: "Unmodifiable views are not snapshots". Worth a look if you touch java / collections.
- @deneil2121▲ 7
Stellar
- @sohumm15▲ 6
Appreciate the write-up on "Unmodifiable views are not snapshots". Useful for anyone using java / collections.
- @dearsohum▲ 6
Appreciate the write-up on "Unmodifiable views are not snapshots". Useful for anyone using java / collections.
- @ohmshawas23▲ 6
Timely
Classic
- @sohmeh▲ 5
Specific and to the point: "Unmodifiable views are not snapshots". Worth a look if you touch java / collections.
Stream.toList()(Java 16+) andList.copyOfboth return snapshots, so they are simple ways to take a stable copy. Got a different fix? Post it in the comments.- @aarya-mehta▲ 1
Specific and to the point: "Unmodifiable views are not snapshots". Worth a look if you touch java / collections.
- @imsa-mehta▲ 1
Good to see "Unmodifiable views are not snapshots" written down. Handy reference for anyone working with java / collections.
Clear note on java / collections. "Unmodifiable views are not snapshots" is the kind of detail that is easy to overlook.
Thanks