I dont understand Access modifiers in OOP (JAVA)
- by Imran
I know this is a silly question but 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 whats 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'm simply trying to understand why we do this?
Thank you in advance;-)