Why Getters and Setters Are Used?
Getters and Setters Are Used to Protect Your Data, Particularly When Creating Classes. for Each Instance Variableinstance variableAn Instance Variable Is a...
Getters and setters are used to protect your data, particularly when creating classes. For each instance variable , a getter method returns its value while a setter method sets or updates its value. Given this, getters and setters are also known as accessors and mutators, respectively.
instance variable
An instance variable is a variable which is declared in a class but outside of constructors, methods, or blocks. Instance variables are created when an object is instantiated, and are accessible to all the constructors, methods, or blocks in the class.
› wiki › Instance_variable