A constant is a value that is set once and then never changes. Java has no single constants keyword, because the same idea applies to variables, methods and classes. Instead you mark the thing you want to protect with the final keyword.
final int MAX_USERS = 500;
// set once, can never changeThe word final is a promise made to the compiler. The compiler then enforces it for you, so a final variable can never be assigned a second time anywhere in your program.
A CONSTANT IN ONE PICTURE
final int MAX_USERS = 500;
| | | |
| | | +--> assigned exactly once
| | +-----------------> name, used everywhere
| +---------------------> type
+---------------------------> final, this can never be reassigned
MAX_USERS = 500; OK, this is the one and only assignment
MAX_USERS = 1000; ERROR, a final variable cannot changeBecause the compiler checks this, final is far safer than a naming convention. A class called ALL_CAPS might still be reassigned by mistake, but a final constant simply will not compile.