Getters and Setters
Learn about getters and setters in OOP.
We'll cover the following
Get and set
In order to allow controlled access to properties from outside the class, getter and setter methods are used.
A getter method allows reading a property’s value.
A setter method allows modifying a property’s value.
It is a common convention to write the name of the corresponding member fields with the get or set command.
Get hands-on with 1200+ tech skills courses.