+ 1
What is the difference between Final and private?
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.
+ 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.
+ 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
0
Thanku so much for your answers.