+ 2
Getters and Setters
When would you say you need to create getters and setters. I mean.. you are doing an exercise or a little program in java, and you just notice you need them? In the examples of this mini-lesson, same thing could be done without them
2 odpowiedzi
+ 2
Methods getX() and setX() are used to interact with private variables, because you couldn't do it in other ways, since they're privates...
+ 1
When is a good practice to declare private variables?
I know that private methods or variables are used to avoid other classes or methods can access ( read) them. But it is just programmer criteria?