why we use encapsulation in java?
1- data controling(数据掌控)
Imaging if you set a person class, and you don’t want his/ her age beyond 200. so, you can set the code into setMethod to control the age under 200.( if age < 200)
2- data security(数据安全)
Private data members cannot be accessed from other class or package.
3 - easy for testing(方便测试)
traking the error more easier.