Home Constants

Constants and magic numbers

Use constants whenever you want to define a single value that won't change during the execution of your program. In particular, whenever you have an arbitrary number or value in your code (a "magic value"), you should use a constant instead.

Declaring constants

Declare all constants to be public static final. All constants must have FULL_UPPERCASE_NAMES, with each word separated by an underscore.