Java Getter Setter Why do we keep instance variables private? We don’t want other classes to depend on them. Moreover it gives the flexibility to change a variable’s type or implementation on a whim or an impulse. Why, then do programmers automatically add getters and setters to their objects, exposing their private variables as if they were public?Accessor methodsAccessors (also known as...
↧