+ 1
What is the difference between "private" and "final" keywords in JAVA?
Along with that is there any way to change the value of final variables?
5 Answers
+ 4
The final keyword is used to declare a variable constant. It cannot change its value throughout the program.
Whereas private members of a class have access only within the class in which they are declared.
Also remember a class cannot be private but it can be final.
+ 2
Avinesh only top level class that cannot be private but inner class can
+ 1
To add further detail to the good answer, final fields can be temporarily stripped of the modifier and changed via the reflection API (just a fun fact, not useful at all regularly :)). Further, final classes are classes which can't be inherited from (cannot be a base class).
0
Taste Thanks, I knew that but didn't wanted to mention since it was a generic answer. What you said also applies for static classes. Anywaysđ