Is it possible to make an object “Read Only” to a method

后端 未结 11 1851
攒了一身酷
攒了一身酷 2020-12-29 06:33

If an object reference is passed to a method, is it possible to make the object \"Read Only\" to the method?

11条回答
  •  醉梦人生
    2020-12-29 06:51

    No. But you could try to clone the object before passing it, so any changes made by the method won't affect the original object.

提交回复
热议问题