How to Declare a Constant in Java
Java does not directly support constants. However, a static final variable is effectively a constant.
The static modifier causes the variable to be available without loading an instance of the class where it is defined.
The final modifier causes the variable to be unchangeable.
Naming Standards for Java Constants
Java constants are normally declared in ALL CAPS.
Underscores normally separate Words in Java constants.
Sample Java Constant Declaration
public class MAX_UNITS { public static final int MAX_UNITS = 25;
Comments - 2 Responses to “How to Declare a Constant in Java”
Sorry but comments are closed at this time.