Mutable vs immutable objects

前端 未结 12 1723
囚心锁ツ
囚心锁ツ 2020-11-22 09:17

I\'m trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method) but I\'m hav

12条回答
  •  轮回少年
    2020-11-22 09:31

    If you return references of an array or string, then outside world can modify the content in that object, and hence make it as mutable (modifiable) object.

提交回复
热议问题