I studied Java static variables.
The correct use of Java static variables 1, constant 2. Shared variables used only within the class It seems that it is.
final static int i = 10;
It's like that. Also, in a concrete example, it seems that jdk itself is a List because java.util.Collections.EMPTY_LIST is specified as final static.
However, you can set the access modifier to private so that it can be referenced and updated only from within that class. That's right
public class Hello{
public static final String Message = "Hello World";
private static String innnerMessage;
}
However, it seems that it is better to avoid sharing variables within the class as much as possible.
I studied below. http://tkmtys.hatenablog.com/entry/2015/10/11/033349
Recommended Posts