What is Getter and Setter(Encapsulation)?
Anonimo
We know that private variables can only be accessed within the same class However, it is possible to access them if we provide public get and set methods. The get method returns the variable value, and the set method sets the value. Syntax for both is that they start with either get or set, followed by the name of the variable, with the first letter in upper case: