Quantcast
Viewing all articles
Browse latest Browse all 14

Answer by npinti for Java setter and getter?

What you are talking about seems to be Encapsulation. Basically the getters and setters allow you to expose class variables as you like and hide any others. Getters and Setters also allow you to perform any other necessary steps such as validation.

Getters and Setters can have different access modifiers themselves, so you can expose data to certain classes but not others by using different access modifiers.


Viewing all articles
Browse latest Browse all 14

Trending Articles