Why do we need Setters and getters when we can use "=" and "return"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why do we need Setters and getters when we can use "=" and "return"?

Function of set & get

20th Nov 2019, 6:23 AM
Little Light 🕯️
Little Light 🕯️ - avatar
3 Answers
+ 5
to protect private data from being accessed / modified directly. https://code.sololearn.com/WuswYAzn9MWs/?ref=app
20th Nov 2019, 6:26 AM
Gordon
Gordon - avatar
0
Thank you very much Gordon
20th Nov 2019, 6:28 AM
Little Light 🕯️
Little Light 🕯️ - avatar
0
Una de las bases principales de la POO es la encapsulación, los setters y getters cumplen parte de esa función. Investiga más sobre la POO y sus beses. Saludos.
20th Nov 2019, 4:21 PM
Jesús Petrona Castro
Jesús Petrona Castro - avatar