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!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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 Réponse
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