Define constant : Constant « Language « Java Tutorial





'public static final' variables are constant.

The naming convention for static final variables is to have them in upper case and separate two words with an underscore. For example:

static final int NUMBER_OF_MONTHS = 12;
static final float PI = (float) 22 / 7;

If you want to make a static final variable accessible from outside the class, you can make it public too:

public static final int NUMBER_OF_MONTHS = 12;
public static final float PI = (float) 22 / 7;










1.6.Constant
1.6.1.Define constant
1.6.2.Define a constant value and use it