There is a big difference: first, enum
, is not a variable, it is a type. A final
variable, say, an int
, can have a single, preset value from among many possible values of int
, while an enum
variable (which could also be final
) can have a value from a set that you declare when defining the enum
.
Here is an example:
enum Color {Red, Green, Blue;}
The declaration above does not define a variable. It defines a set of values a variable of type Color
could have, if you choose to declare one:
Color backgroundColor = Color.Red;
Now you have a non-final variable of an enumerated type Color
. Its value can change, but it must be one of the three values defined as part of the enum
.
In practice, you use an enum
when you model a something with a fixed number of states, to which you would like to give a name. You could use one or more final
variables for that, too, - in fact, this has been done a lot before enum
s were introduced. For example, Java's Calendar
class uses static final int
constants for the various parts of the date, where an enum
would have worked better.