Why is it better to use a getter to call properties?

Is it better to use a getter to call properties of a object or class than calling the property directly?

Hello! From what I know , it is better to use the getter to call a property, as you can therefore control what type of data is assigned to that property, which will enable you to more easily code the rest of your program, as you know what data types will be stored in the property. See this page for more.
I hope this helps!

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.