Nov 3, 2018

Java Constant Naming Conventions

  • Use ALL_UPPER_CASE for your named constants, separating words with the underscore character. For example, use TAX_RATE rather than taxRate or TAXRATE.
  • Avoid using magic numbers in the code. Magic numbers are actual numbers like 27 that appear in the code that require the reader to figure out what 27 is being used for. Consider using named constants for any number other than 0 and 1.