About
This is a blog post about keywords
public static final
and private static final
in JAVA world. To be honest, answers came from Stackoverflow. Putting them together is what I have done in this blog.About static
There is one and only one copied in the memory. Even though there are millions of instances, they are all accessing the same pieces of memory if it had been specified with
static
. Refer to here for further explanation.About final
You are not allowed to change value of a variable if it had been defined with
final
. Refer to here for explanation.public final static vs private final static
The best practice is using the latter one. For the explanation, please refer to here
沒有留言:
張貼留言