Introduction
Getter and setter methods help us safely get or change the value of a private variable in a class.
When you want to control how a variable is read or changed.
When you want to hide the details of how data is stored inside a class.
When you want to check or change values before saving them.
When you want to keep variables private but still allow access.
When you want to make your code easier to maintain and understand.