Perry Terrance wrote:I know this is probably answered before, but can anyone give me a quick answer on this.
If I do a Collections.unmodifiableMap - the returned Map is immutable (read-only), but what about the elements inside the Map?
Perry Terrance wrote:If I do a Collections.unmodifiableMap - the returned Map is immutable (read-only), but what about the elements inside the Map? If the Map itself was filled with a bunch of different objects such as HashTables, Arrays, etc, can I modify them? Or is this whole unmodifiable property a recursive one - that goes down all the object layers inside?
Perry Terrance wrote:On a side note, I wonder if there was ever a way to do this recursively though, if I ever wanted a full-recursive immutability...
Perry Terrance wrote:
So "shallow" immutability is what I need since I need to tinker with the actual objects inside the Map...
On a side note, I wonder if there was ever a way to do this recursively though, if I ever wanted a full-recursive immutability...
Perry Terrance wrote:I know this is probably answered before, but can anyone give me a quick answer on this.
If I do a Collections.unmodifiableMap - the returned Map is immutable (read-only), but what about the elements inside the Map? If the Map itself was filled with a bunch of different objects such as HashTables, Arrays, etc, can I modify them? Or is this whole unmodifiable property a recursive one - that goes down all the object layers inside?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jeff Verdegan wrote:Sorry, but that analogy doesn't quite hold. If you're passed an array, you can change the value of one of the array's elements.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Consider Paul's rocket mass heater. |