So... um... GETTER and SETTER are just public methods, what contain possibility to modify and show us private variables? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

So... um... GETTER and SETTER are just public methods, what contain possibility to modify and show us private variables?

right? and why can't we just give to those methods abother names?

20th Dec 2016, 7:21 AM
Nochains
Nochains - avatar
1 ответ
0
Yes... They allow you to access private class members, and if you wanted to, you could name them however you want, but the convention is to name them getVariableName and setVariableName.
20th Dec 2016, 7:46 AM
Gabe Rust
Gabe Rust - avatar