What is the use of encapsulation when I'm able to change the property values with setter methods?

前端 未结 15 2068
情深已故
情深已故 2020-12-08 11:08

I try to understand a lot of times but I failed to understand this.

Encapsulation is the technique of making the fields in a class private and provi

15条回答
  •  误落风尘
    2020-12-08 11:30

    The real use of encapsulation is also in the fact that you can do additional checks/processing on the way the values are set.

提交回复
热议问题