Getter and Setter | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Getter and Setter

How getter and setter protect your data ???? I don't understand😔😓

29th Mar 2017, 10:44 PM
1 Answer
+ 3
you have to declare your fields as private so no other class can see it fields. If a other class want to use them it has to use the getter or setter
29th Mar 2017, 11:09 PM