I'm a high school computer science student. I've tried asking my teacher and done a lot of personal research but I am really struggling with accessor and mutator methods. I'm curious why you would ever use these methods. If you wanted to access variables of an object, why not just make them public? Thanks!
Asked
Active
Viewed 13 times
0
-
And also as posted by @ChsPly76 *Because 2 weeks (months, years) from now when you realize that your setter needs to do more than just set the value, you'll also realize that the property has been used directly in 238 other classes* – Scary Wombat Nov 29 '16 at 05:30
-
thank you so much for your help – user7223592 Nov 29 '16 at 05:34