Access modifiers in Object-Oriented Programming

Posted by Imran on Stack Overflow See other posts from Stack Overflow or by Imran
Published on 2010-03-11T20:17:24Z Indexed on 2010/03/11 20:29 UTC
Read the original article Hit count: 363

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. ;-)

© Stack Overflow or respective owner

Related posts about java

Related posts about oop