Java – the difference between the final variable and the static final variable
•
Java
I'm just studying the final data members. What's the difference between the final variable and the static final variable?
I know that a static and final field has only one storage space, and the final variable will have storage associated with each instance
However, even if I declare only one variable, only final, it is still the same for all objects, because I need to initialize them in the program itself, not at run time
So basically there is no difference between the two, except for memory related problems?
Solution
No, non - static end members can be initialized in constructors It cannot be reassigned later
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码