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

后端 未结 11 1918
攒了一身酷
攒了一身酷 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:54

    making it implement a interface which has only read only methods (no setter methods) this gives a copy of an object (road-only copy) and returning the read only instance of interface instead of returning the instance of an object itself

提交回复
热议问题