Is there any naming convention for java constant variable?
Normally we use variables with names containing uppercase letters and underscores(_).
For example:
public final class DeclareConstant {
public static final String CONSTANT_STRING = "some constant";
public static final int CONSTANT_INTEGER = 5;
}
解决方案
Yes. That is it. It is often used for enum as well.
The only common exception is for logging where you might see
private static final Logger log = Logger.getLogger(getClass().getName());
but I prefer LOG
I often write this as UPPER_CASE, but I also write TitleCase for classes and camelCase for variables and methods.