0

I am a beginner programmer and I am having trouble understanding the need for getters and setters in Java.I know that getters are used to read a variable that may be private and setters are used to change that variable. My question is are getters and setters mainly useful for when there are multiple programmers writing code for one application? or do the access modifiers protect the declared variables from being changed by other parts of the code within the application?

Vernell
  • 23
  • 3
  • Second option, the method allow to centralize the accesses to the attribut, you can write the setter or not, you can make verification on the value to set – azro Jan 17 '20 at 18:52
  • Thank you. I understand much better now. – Vernell Jan 18 '20 at 03:43

0 Answers0