Java Constants

Published December 10th 2009 by
Filed under Java

A constant in java is a variable with a pre-defined value. To declare a variable as a constant, use the final modifier:

public static final int VARIABLENAME = 0;

VARIABLENAME can’t ever be assigned to a different value.

The full name for this declaration is an enumerated constant.