I dont understand Access modifiers in OOP (JAVA)

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:24 UTC
Read the original article Hit count: 617

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

© Stack Overflow or respective owner

Related posts about java

Related posts about oop