The question of encapsulation

I know that encapsulation connects members and their behavior in one object. And that made me think that members should be private. Does this mean if a class with public members does not comply with the 100% encapsulation rule?

thank

+3
source share
4 answers

Encapsulation is a collection of data and hiding data. Java allows you to provide data, but you must have a very good reason if you decide to do so. Member variables should be private by default and only increase to higher visibility if absolutely necessary.

+6
source

, ( ) getter, seters, property .. , java (getters seters),.net() .. - .

, ? , . , , 1 10. , , . , , int, , , "", .

!

+3

. / , .

0

- , , , . , setter .

0
source

Source: https://habr.com/ru/post/1745169/


All Articles