+ 13
What is main difference in final and static variable?
4 Respostas
+ 1
in java you can write :
public final static Double PI=3.14;
to obtain a costant, it is static because is not a field of an instance but a value of the class.
It's final because its value can't change after initialization.
A costant should be ever static, if isn't, you waste a lot of memory to save in every instance of the class the same thing
+ 12
Once it has been assigned, the value of the final variable cannot change. static means it belongs to the class not an instance, this means that there is only one copy of that variable/method shared between all instances of a particular Class.
+ 3
final variable value is unchangeable while static variable value is.
0
In Java Scrip you must write
var: x=number;