Why do we need to use getters and setters?

Question

Why do we need to use getters and setters?

Answer

There are many advantages to using getters and setters. The general gist is that using them allows us to have more control with what happens when actions are performed on an object. We don’t need to use getters and setters, but it is a common design pattern.