Java naming convention for static final variables [duplicate]

That’s still a constant. See the JLS for more information regarding the naming convention for constants. But in reality, it’s all a matter of preference.


The names of constants in interface types should be, and final
variables of class types may conventionally be, a sequence of one or
more words, acronyms, or abbreviations, all uppercase, with components
separated by underscore "_" characters. Constant names should be
descriptive and not unnecessarily abbreviated. Conventionally they may
be any appropriate part of speech. Examples of names for constants
include MIN_VALUE, MAX_VALUE, MIN_RADIX, and MAX_RADIX of the
class Character.

A group of constants that represent alternative values of a set, or,
less frequently, masking bits in an integer value, are sometimes
usefully specified with a common acronym as a name prefix, as in:

interface ProcessStates {
  int PS_RUNNING = 0;
  int PS_SUSPENDED = 1;
}

Obscuring involving constant names is rare:

  • Constant names normally have no lowercase letters, so they will not normally obscure names of packages or types, nor will they normally shadow fields, whose names typically contain at least one lowercase letter.
  • Constant names cannot obscure method names, because they are distinguished syntactically.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)