Access modifiers in Object-Oriented Programming
- by Imran
I don't understand Access Modifiers in OOP. Why do we make for example in Java instance variables private and then use public getter and setter methods to access them? I mean what's the reasoning/logic behind this?
You still get to the instance variable but why use setter and getter methods when you can just make your variables public?
please excuse my ignorance as I am simply trying to understand why?
Thank you in advance. ;-)