Public property VS Private property with getter?
问题 This question has puzzled me for a while. A public property that can be accessed directly or a private property with getter? Which one is better/correct and why? 回答1: Exposing fields directly is considered a bad practice. It is better to keep the field private and only expose the getter and setter. One advantage is that you can choose different access levels for the getter and setter, whereas a field has only a single access level. Another advantage of using getters is that it allows you to