Is guava's ImmutableXXX really immutable?

前端 未结 3 1441
陌清茗
陌清茗 2021-01-05 01:23

I have been using guava for some time now and truly trusted it, until I stumbled of an example yesterday, which got me thinking. Long story short, here it is:



        
3条回答
  •  情歌与酒
    2021-01-05 01:55

    You mix the immutability of the list and the immutability of the objects it contains. In an immutable collection you cannot add/remove objects, but if the object it contains are mutable you can modify them after get()ing them.

提交回复
热议问题