Java does not directly support constants. However, a static final variable is effectively a constant.
Ex: public static final int FOUNDING_YEAR = 2001;
Naming Standards for Java Constants
Although these aren’t syntactical rules, they are widely used as accepted conventions.
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;
}
No comments:
Post a Comment