Why can we change the unmodifiable list if we have the original one?

前端 未结 7 763
时光取名叫无心
时光取名叫无心 2020-12-10 15:56

By looking at the code of Collections class, i got to know that when we are using the method unmodifiableList(List list) or unmodifiableCollection(Coll

7条回答
  •  盖世英雄少女心
    2020-12-10 16:16

    I believe the secret lies in implementation details... Collection.unmodifiableList() will simply give you decorated modifiable list. I mean unmodifiable list contains reference to modifiable list internally.

提交回复
热议问题