+ 1
whats the difference if i declare a variable public or not?
1 Odpowiedź
+ 3
If you set an attribute to public, it can be accessed from outside the class. It is usually a good practice to set all attributes to private, and provide public getters and setters (ie methods to get/set an attribute respectively) as needed.