What is the difference between variables declared as final and private?

6

What's the difference between these two types of variables and why they can not be accessed in certain parts of the code? I read about private, public, and abstract methods, but I did not understand the use of the ending.

    
asked by anonymous 27.10.2014 / 22:12

1 answer

8
  • A variable of type final can be initialized only once, either through an initializer or through an assignment.
  • A variable of type private can only be modified and accessed within the class itself directly. To access and modify a variable of this type outside the class in question, you must use getters and setters of the variable.
  • 27.10.2014 / 22:25