+ 1

What is the difference between Final and private?

13th Dec 2016, 5:20 PM
Mayur More
Mayur More - avatar
4 Réponses
+ 1
private is a keyword. It is used when use declare a varible or a method in class. If a varible or method are declared as private. You can access them in the class that you declare the varible or the method. Outside of the class can't access them. final is a keyword. It is used when you declare a varible or a method in class. If a varible is declared as final. You can't change the value of the varible( if you do so, errors will appear). If a method is declared as final, the method can't be overrided.
13th Dec 2016, 5:51 PM
The PGDeveloper
The PGDeveloper - avatar
+ 1
final means constant. you can not change value after assign in to variable which is final. private means you can not use that variable directly outside that class or scope but you can change that value as many time you want but in their region.
13th Dec 2016, 5:51 PM
Yash Gandhi
Yash Gandhi - avatar
+ 1
Final means constant, which meand that it can only be assigned a value once. Private means that u can't acces it by the . Operator
4th Mar 2017, 4:36 PM
Tom Larsson
Tom Larsson - avatar
0
Thanku so much for your answers.
13th Dec 2016, 5:54 PM
Mayur More
Mayur More - avatar